#include <bits/stdc++.h>

using namespace std;
int x,y;
int n,m;
long long niz[100010];
int main (){
    scanf("%d %d",&n,&m);
    for(int i = 1; i <= n; i++){
        scanf("%lld",&niz[i]);
    }
    long long rez=0;
    for(int i = 1; i <= m; i++){
        scanf("%d %d",&x,&y);
        if(niz[x]>=0 and niz[y]>=0){
            rez+=niz[x]+niz[y];
//            cout << rez << endl;
            continue;
        }
        if(niz[x]>=0 and niz[y]<=0){
            if(niz[x]+niz[y]>=abs(niz[y])-niz[x]){
                rez+=niz[x]+niz[y];
            }else{
                rez+=abs(niz[y])-niz[x];
            }
//            cout << rez << endl;
            continue;
        }
        if(niz[x]<=0 and niz[y]>=0){
            if(niz[y]+niz[x]>=abs(niz[x])-niz[y]){
                rez+=niz[y]+niz[x];
            }else{
                rez+=abs(niz[x])-niz[y];
            }
//            cout << rez << endl;
            continue;
        }
        if(niz[x]<0 and niz[y]<0){
            rez+=abs(niz[x])+abs(niz[y]);
//            cout << rez << endl;
        }
    }
    printf("%lld\n",rez);
return 0;
}