#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    long long i,n,m,p,q,s=0;
    cin>>n>>m;
    vector<long long> A(n),P(n),N(n);
    vector<pair<long long,long long>> V(m);
    for(i=0;i<n;i++)cin>>A[i];
    for(i=0;i<m;i++)cin>>V[i].first>>V[i].second;
    for(i=0;i<n;i++)
    {
        P[i]=0;
        N[i]=0;
    }
    for(i=0;i<m;i++)
    {
        p=A[V[i].first-1]+A[V[i].second-1];
        q=-A[V[i].first-1]-A[V[i].second-1];
        if(p>=q)
        {
            P[V[i].first-1]++;
            P[V[i].second-1]++;
        }
        else
        {
            N[V[i].first-1]++;
            N[V[i].second-1]++;
        }
    }
    for(i=0;i<n;i++)s+=A[i]*(P[i]-N[i]);
    cout<<s;
    return 0;
}