#include <iostream>
#include <stdlib.h> 
#define MAXN 100001

using namespace std;

int niz[MAXN];

int main()
{
	int n, m;
	int rez = 0;
	int br1, br2;
	cin >> n >> m;
	for (int i = 0; i<n; i++)
	{
		cin >> niz[i];
	}
	for (int i = 0; i<m; i++)
	{
		cin >> br1 >> br2;
		if ((niz[br1 - 1] < 0 && niz[br2 - 1] > 0) || (niz[br1 - 1] > 0 && niz[br2 - 1] < 0))
		{
			if (abs(niz[br1 - 1]) >= abs(niz[br2 - 1])) rez += abs(niz[br1 - 1]) - abs(niz[br2 - 1]);
			else rez += abs(niz[br2 - 1]) - abs(niz[br1 - 1]);
		}
		else if ((niz[br1 - 1]>0 && niz[br2 - 1] > 0) || (niz[br1 - 1] < 0 && niz[br2 - 1] < 0)) rez += niz[br1 - 1] + niz[br2 - 1];
	}
	cout << rez;
	return 0;
}