#include <iostream>
#include <vector>
using namespace std;
int main(){
	int n,m,i,x=0,p=0,t;
	cin>>n>>m;
	vector <int> a(n);
	vector <int> b(m);
	vector <int> b2(m);
	vector <int> c(n);
	for(i=0;i<n;i++){
		cin>>a[i];
		c[i]=0;
	}
	for(i=0;i<m;i++){
		cin>>b[i]>>b2[i];
		c[b[i]-1]++;	
		c[b2[i]-1]++;
	}
		for(i=0;i<n;i++){
		t=a[i]*c[i];
		x=t+x;
		t=a[i]*(-1)*c[i];
		p=t+p;
	}
	if(x>p) cout<<x;
	else cout<<p;
    return 0;
}