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

typedef long long ll;

int main() {
	int n, m; cin >> n >> m;
	vector<ll> a(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]++;
		} else {
			p[x]++; p[y]++;
		}
	}
	ll sum = 0;
	for(int i = 0; i < n; i++) {
		if(p[i] == np[i]) continue;
		sum += a[i] * (p[i] - np[i]);
	}
	cout << sum << "\n";
	return 0;
}