#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
using namespace std;
ll t,n,a[100005],u,v,res,mx,m;
pair<ll,ll> p[100005];
int main () {
cin.tie(NULL);
ios_base::sync_with_stdio(false);
cin>>n>>m;
for(int i=1;i<=n;i++){
    cin>>a[i];
}
for(int i=1;i<=m;i++){
    cin>>u>>v;
    mx=max(abs(a[u]),abs(a[v]));
    if(mx==a[u]*-1 or mx==a[v]*-1){p[u].ss++;p[v].ss++;}
    else{p[u].ff++;p[v].ff++;}
}
for(int i=1;i<=n;i++){
    res+=a[i]*(p[i].ff-p[i].ss);
}
cout<<res<<endl;
return 0;
}