#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <stack>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	int n,m;
	cin >> n >> m;
	long long sreca = 0;
	long long a[n];
	long long b[2][m];
	for(int i = 0; i < n; ++i)cin >> a[i];
	for(int i = 0; i < m; ++i)cin >> b[0][i] >> b[1][i];
	for(int i = 0; i < m; ++i)
	{
		if(-a[b[0][i]-1] - a[b[1][i]-1] >= a[b[0][i]-1] + a[b[1][i]-1])
		{
			sreca += -a[b[0][i]-1] - a[b[1][i]-1];
		}
		else
		{
			sreca += a[b[0][i]-1] + a[b[1][i]-1];
		}
	}
	
	cout << sreca;
}