#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main() {
	int n, m; cin >> n >> m;
	vector<ll> a(n);				// intialie n+1 so that you dony need x-- and y-- ? loops start from 1 and go to <= n
	vector<int> p(n);
	vector<int> np(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for(int i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		x--; y--;
		if(abs(min(a[x], a[y])) > abs(max(a[x], a[y]))) {
			np[x]++; np[y]++;
			//cout << "np: " << x << " " << y << endl;
			//cout << "a: " << a[x] << " " << a[y] << endl;
		} else {
			p[x]++; p[y]++;
			//cout << "p: " << x << " " << y << endl;
			//cout << "a: " << a[x] << " " << a[y] << endl;
		}
	}
	ll sum = 0;

	//for(auto x : p) cout << x << " ";
	//cout << endl;
	//for(auto x : np) cout << x << " ";
	//cout << endl;

	for(int i = 0; i < n; i++) {
		if(p[i] == np[i]) continue;
		sum += a[i] * (p[i] - np[i]);
		//cout << sum << endl;
	}
	cout << sum << "\n";
	return 0;
}