#include <iostream>
#include <cmath>
using namespace std;

int main(int argc, char** argv) {
	int n, m, s, x, y;
	cin >> n >> m;
	bool t1 = true;
	int a[n]
	for(int i = 0; i<n; i++)
	{
		cin >> a[i];
		if(a[i] != 1) t1 = false;
	}
	if(t1)
	{
		for(int i = 0; i<m; i++)
		{
			cin >> x >> y;
		}
		s = 2*n;
	}
	else
	{
		s = 0;
		int id, z;
		int ax = abs(a[x]);
		int ay = abs(a[y])
		for(int i = 0; i<m; i++)
		{
			cin >> x >> y;
			if((ax > ay) || (ax==ay && ax<ay)
			{
				id = x;
			}
			else
			{
				if((ay > ax) || (ax==ay %% ax>ay)
				{
					id = y;
				}
			}
			z = a[id] - abs(a[id]);
			s+= a[x]*z + a[y]*z;
		}
	}
	cout << s << endl;
	return 0;
}