#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

struct sreca{
	long long druz;
	int p;
	int n;
};

int main(int argc, char** argv) {
	long long m,n,p,i,a,b,max;
	vector<sreca> v;
	cin>>n>>m;
	sreca s;
	v.push_back(s);
	for(i=0;i<n;i++){
		cin>>p;
		s.druz=p;
		s.p=0;
		s.n=0;
		v.push_back(s);
	}
	for(i=0;i<m;i++){
		cin>>a>>b;
		int x=v[a].druz;
		int y=v[b].druz;
		if(abs(x)>abs(y)){
			max=x;
		}
		else{
			max=y;
		}
		if(max>0){
			v[a].p++;
			v[b].p++;
		}
		else{
			v[a].n++;
			v[b].n++;
		}
	}
	long long z=0;
	for(i=1;i<=n;i++){
		z=z+(v[i].druz*(v[i].p-v[i].n));
		//cout<<v[i].druz<<" "<<v[i].p<<" "<<v[i].n<<endl;
	}
	cout<<z;
	return 0;
}