#include<bits/stdc++.h>
using namespace std;
long long nadjiIndeks(long long x, long long a[], int n, bool isk[])
{
    for(int i=0;i<n;i++)
        if(isk[i]==false && x==a[i]) return i;
}
int main()
{
    int n,m,sreca=0;
    cin>>n>>m;
    long long d[n];
    long long cd[n];
    bool isk[n]={false};
    for(int i=0;i<n;i++)
    {
        cin>>d[i];
        cd[i]=d[i];
    }
    sort(cd,cd+n);
    int p[m*2];
    for(int i=0;i<2*m;i+=2)
        cin>>p[i]>>p[i+1];
    int odnosi[n]={0};
    for(int i=0;i<n;i++)
    {
        int ind=nadjiIndeks(cd[i],d,n,isk);
        isk[ind]=true;
        for(int j=0;j<2*m;j++)
        {
            if(p[j]==ind+1)
                if(j%2==0)
                {
                    odnosi[p[j]-1]+=1*(d[p[j]-1]/abs(d[p[j]-1]));
                    odnosi[p[j+1]-1]+=1*(d[p[j+1]-1]/abs(d[p[j+1]-1]));
                }
                else
                {
                    odnosi[p[j]-1]+=1*(d[p[j]-1]/abs(d[p[j]-1]));
                    odnosi[p[j-1]-1]+=1*(d[p[j-1]-1]/abs(d[p[j-1]-1]));
                }
        }
    }
    for(int i=0;i<n;i++)
    {
        sreca+=(d[i]*odnosi[i]/2);
    }
    cout<<sreca;
}