#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n, m;
    cin >> n >> m;
    pair<long long, long long> drugari[n];
    for(long long i = 0 ; i < n ; i++){
        long long druzeljubivost;
        cin >> druzeljubivost;
        drugari[i].first = druzeljubivost;
        drugari[i].second = 0;
    }
    for(long long i = 0 ; i < m ; i++){
        long long p1, p2;
        cin >> p1 >> p2;
        p1--;
        p2--;
        if(abs(drugari[p1].first) > abs(drugari[p2].first)){
            if(drugari[p1].first < 0){
                drugari[p1].second--;
                drugari[p2].second--;
            }
            else{
                drugari[p1].second++;
                drugari[p2].second++;
            }
        }
        else{
            if(drugari[p2].first < 0){
                drugari[p1].second--;
                drugari[p2].second--;
            }
            else{
                drugari[p1].second++;
                drugari[p2].second++;
            }
        }

    }
    long long zbir = 0;
    for(long long i = 0 ; i < n ; i++){
        zbir += (drugari[i].first * drugari[i].second);
    }
    cout << zbir;
    return 0;
}