#include<iostream>
using namespace std;

int ukupnasreca = 0;
int main()
{
	int n, m;
	cin >> n;
	cin >> m;
	int druz[n];
	int poz[n][n];
	int sreca[n];
	for (int j=0;j<n;j++)
	{
		for (int i=0;i<n;i++)
		{
			poz[j][i] = -1;
			poz[i][j] = -1;
		}
	}
	for (int j=0;j<n;j++)
	{
		cin >> druz[j];
	}
	//BITNO: DRUZELJUBIVOST PRVOG TAKMICARA = DRUZ[0], DRUZ I-TOG TAKMICARA = DRUZ[I-1]
	for (int j=0;j<m;j++)
	{
		int x, y;
		cin >> x;
		cin >> y;
		x -= 1;
		y -= 1;
		poz[x][y] = 0;
		poz[y][x] = 0;
	}	
	for (int j=0;j<n;j++)
	{
		for (int i=0;i<n;i++)
		{

			if (i!=j and (abs(druz[j]) >= abs(druz[i]) and poz[j][i] != -1))
			{
				if (druz[j] < 0)
				{
					poz[j][i] = 2;
					poz[i][j] = 2;
				}
				else
				{
					poz[j][i] = 1;
					poz[i][j] = 1;
				}
			}
		}	
	}
	for (int j=0;j<n;j++)
	{
		int brpr = 0;
		int brnpr = 0;
		for (int i=0;i<n;i++)
		{
			if (i!=j and (poz[j][i] == 1))
			{
				brpr += 1;
			}
			else if (i!=j and (poz[j][i] == 2))
			{
				brnpr += 1;
			}
		}
		sreca[j] = (brpr-brnpr)*druz[j];
		ukupnasreca += sreca[j];
	}
	cout << ukupnasreca << endl;
}