#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n, m, x, y;
	cin >> n >> m;
	vector<int> a(n);
	for (int i = 0;i < n;i++)
		cin >> a[i];
	vector<int> b(n);
	for (int i = 0;i < m;i++) {
		cin >> x >> y;
		b[x - 1]++;
		b[y - 1]++;
	}
	x = 0;
	y = 0;
	for (int i = 0;i < n;i++) {
		x += a[i] * (-b[i]);
		y += a[i] * b[i];
	}
	if (x > y)cout << x << endl;
	else cout << y << endl;