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

int main(){

    int n,m;
    cin >> n >> m;
    int list1[n];
    for (int i=0; i<n; i++){
        int x;
        cin >> x;
        list1[i] = x;
    }
    int poeni = 0;
    for(int i=0; i<m; i++){
        int a1,a2;
        cin >> a1>> a2;
        int a = list1[a1-1];
        int b = list1[a2-1];
        if (b==0 || a==0){
            poeni += fmax(abs(a),abs(b));
        }else if(a*b>0){
            poeni += abs(a) + abs(b);
        }else if(a*b<0){
            poeni += fmax(abs(a),abs(b)) - fmin(abs(a),abs(b));
        }
    }

    cout << poeni << endl;

    return 0;
}