#include <iostream>

using namespace std;

int main()
{
	int N, M;
	cin >> N, M;
	int tak[N+1], s = 0;

	for (int i = 1;i <= N;i++)
	{
		cin >> tak[i];
	}
	for (int i = 0;i < M;i++)
	{
		int Xi, Yi;
		cin >> Xi >> Yi;
		if (tak[Xi] > 0 && tak[Yi] > 0)
		{
			s += tak[Xi];
			s += tak[Yi];
		}
		else if (tak[Xi] < 0 && tak[Yi] < 0)
		{
			
			s -= tak[Xi];
			s -= tak[Yi];
		}
		else if (tak[Xi] < 0 )
		{
			if ((-tak[Xi]) > tak[Yi])
			{
				s -= tak[Xi];
				s -= tak[Yi];
			}
			else
			{
				s += tak[Xi];
				s += tak[Yi];
			}
			
		}
		else if (tak[Yi] < 0 )
		{
			if ((-tak[Yi]) > tak[Xi] )
			{
				s -= tak[Xi];
				s -= tak[Yi];
			}
			else
			{
				s += tak[Xi];
				s += tak[Yi];
			}
			
		}
		
	}
	cout << s;
	return 0;
}