#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll N,niz[100005],M,u1,u2,res;
int main(){
    cin>>N>>M;
    for(int i=1;i<=N;i++)
        cin>>niz[i];
    while(M--){
        cin>>u1>>u2;
        res+=max(-niz[u1]-niz[u2],niz[u1]+niz[u2]);
    }
    cout<<res<<endl;
    return 0;
}