#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);
	vector<bool> been(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--;
		been[x] = true;
		been[y] = true;
		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(!been[i]) continue;
		sum += a[i] * (p[i] - np[i]);
	}
	cout << sum << "\n";
	return 0;
}