#include <iostream>
#include <algorithm>
#include <vector>

#define maxn 100000

using namespace std;

struct poz
{
	int allies;
	int enemies;

	poz(int a, int b)
	{
		allies = a;
		enemies = b;
	}
	poz()
	{
		allies = 0, enemies = 0;
	}
};

int drz[maxn + 5];
poz studs[maxn + 5];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(); cout.tie();
	long long res = 0;
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> drz[i];
	for (int i = 1; i <= m; i++)
	{
		int x, y;
		cin >> x >> y;
		if (drz[x] < 0 && drz[y] >= 0) 
		{
			if (-drz[x] > drz[y])
			{
				studs[x].enemies++;
				studs[y].enemies++;
			}
			else
			{
				studs[x].allies++;
				studs[y].allies++;
			}
		}
		else if (drz[y] < 0 && drz[x] >= 0)
		{
			if (-drz[y] > drz[x])
			{
				studs[y].enemies++;
				studs[x].enemies++;
			}
			else
			{
				studs[y].allies++;
				studs[x].allies++;
			}
		}
		else if (drz[y] < 0 && drz[x] < 0)
		{
			studs[x].enemies++;
			studs[y].enemies++;
		}
		else if (drz[y] >= 0 && drz[x] >= 0)
		{
			studs[x].allies++;
			studs[y].allies++;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		res += (long long)drz[i] * ((long long)studs[i].allies - studs[i].enemies);
	}

	cout << res << endl;
}