#include <bits/stdc++.h>
#define MAXN 100010

using namespace std;

long long a[MAXN];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	int n, m;
	
	cin >> n >> m;
	
	for(int i = 0; i < n; i++) cin >> a[i];
	
	long long s = 0;
	
	while(m--)
	{
		int i, j;
		
		cin >> i >> j;
		
		i--;
		j--;
		
		if(a[i] * a[j] >= 0) s += abs(a[i]) + abs(a[j]);
		else s += max(abs(a[i]), abs(a[j])) - min(abs(a[i]), abs(a[j]));
	}
	
	cout << s;
	
	return 0;
}