#include <iostream>
#include <algorithm>
#include <vector>
#define ll long long
using namespace std;
vector<ll> a;
vector<ll> c;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cerr.tie(0);
	int n, m;
	cin >> n >> m;
	a.resize(n);
	c.resize(n, 0);
	for (int i = 0; i < n; i++)cin >> a[i];
	while (m--) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		ll p = a[x] * (c[x] + 1) + a[y] * (c[y] + 1);
		ll q = a[x] * (c[x] - 1) + a[y] * (c[y] - 1);
		if (p >= q) {
			c[x]++;
			c[y]++;
		}
		else {
			c[x]--;
			c[y]--;
		}
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += (a[i] * c[i]);
	}
	cout << ans;
	return 0;
}