#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;
		poznanstvo z;
		z.a = x;
		z.b = y;
		p.push_back(z);		
	}
	for(int i=0; i<p.size(); i++){
		int s1, s2;
		s1 = dr[p[i].a]*1+dr[p[i].b]*1;
		s2 = dr[p[i].a]*-1+dr[p[i].b]*-1;
		if(s1>s2){
			r[p[i].a] += dr[p[i].a]*1;
			r[p[i].b] += dr[p[i].b]*1;	
		}
		else{
			r[p[i].a] += dr[p[i].a]*-1;
			r[p[i].b] += dr[p[i].b]*-1;	
		}	
	}
	int rezultat = 0;
	for(int i=1; i<r.size(); i++){
		rezultat+=r[i];	
	}
	cout << rezultat;
}