#include <iostream>

using namespace std;

int main() {
	long long druz[100000];
    int parovi[100000][2];
    int n, m;
	static int pr[100000], ne[100000];
	
	cin >> n >> m;
	
	for (int i = 0; i < n; i++)
		cin >> druz[i];
		
	for (int i = 0; i < m; i++) {
		cin >> parovi[i][0] >> parovi[i][1];
		
		if (druz[parovi[i][0]-1] > 0 && druz[parovi[i][1]-1] > 0) {
			
			pr[parovi[i][0]-1]++;
			pr[parovi[i][1]-1]++;
			
		}
		else {
			
			ne[parovi[i][0]-1]++;
			ne[parovi[i][1]-1]++;
			
		}
	}
	
	int pom = 0;
		
	for (int i = 0; i < n; i++) {
		//cout << i << " prij: "<< pr[i] << " nepr: " << ne[i] << endl;
		pom += druz[i]*(pr[i]-ne[i]);
	}
	
	cout << pom;
	return 0;
}