#include <iostream>
using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long

int main(int argc, char** argv) {
	int n,m,x,y;
	ll res=0,res1=0;
	ll niz[100000],niz1[100000];
	cin>>n>>m;
	for(int i=1;i<=n;++i){
		cin>>niz[i];
	}
	for(int i=0;i<m;++i){
		cin>>x>>y;
		++niz1[x];
		++niz1[y];
	}
	for(int i=1;i<=n;++i){
		res+=niz[i]*niz1[i];
		res1+=niz[i]*(0-niz1[i]);
	}
	ll max1=max(res,res1);
	cout<<max1;
	return 0;
}