#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define ll long long

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int nodes_count, edges_count;
	cin >> nodes_count >> edges_count;

	vector<ll> friendliness(nodes_count+1);
	for (size_t i = 1; i <= nodes_count; i++)
		cin >> friendliness[i];
	
	ll solution = 0;
	for (size_t i = 0; i < edges_count; i++)
	{
		int person1, person2; cin >> person1 >> person2;
		ll best_choice = max(friendliness[person1] + friendliness[person2], -friendliness[person1] - friendliness[person2]);
		solution += best_choice;
	}

	cout << solution;
	return 0;
}