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

int n, m;
int u, v;
long long ans;
int ar[100005];
int cnt[100005];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> ar[i];
	for (int i = 0; i < m; i++) {
		cin >> u >> v;
		if (ar[u] >= 0 && ar[v] >= 0) {
			cnt[u]++;
			cnt[v]++;
		} else if (ar[u] <= 0 && ar[v] <= 0) {
			cnt[u]--;
			cnt[v]--;
		} else {
			if (ar[u] >= 0 && ar[v] <= 0) swap(u, v);
			if (abs(ar[u]) > abs(ar[v])) {
				cnt[u]--;
				cnt[v]--;
			} else {
				cnt[u]++;
				cnt[v]++;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		ans += 1LL * ar[i] * cnt[i];
	}
	cout << ans << '\n';
	return 0;
}