#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

struct poznanstvo{
	int a;
	int b;
};

int main(){
	int n, m;
	cin >> n >> m;
	vector<long long int> dr;
	vector<poznanstvo> p;
	vector<int> r;
	dr.push_back(0);
	r.push_back(0);
	
	poznanstvo k;
	k.a = -1;
	k.b = -1;
	p.push_back(k);
	for(int i=1; i<=n; i++){
		long long int x;
		cin >> x;
		dr.push_back(x);
		r.push_back(0);
	}
	for(int i=1; i<=m; i++){
		int x, y;
		cin >> x >> y;
		int s1, s2;
		s1 = dr[x]*1+dr[y]*1;
		s2 = dr[x]*-1+dr[y]*-1;
		if(s1>s2){
			r[x] += dr[x]*1;
			r[y] += dr[y]*1;
		}
		else{
			r[x] += dr[x]*-1;
			r[y] += dr[y]*-1;
		}
	}
	int rezultat = 0;
	for(int i=1; i<r.size(); i++){
		rezultat+=r[i];	
	}
	cout << rezultat;
}