#include <iostream>

using namespace std;

int main()
{
    int n,m,i,zbir1=0,zbir2=0;
    cin>>n;
    cin>>m;
    int a[n],x,y,veze[n];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        veze[i]=0;
    }
    for(i=1;i<=m;i++)
    {
            cin>>x;
            veze[x]++;
            cin>>y;
            veze[y]++;

    }
    for(i=1;i<=n;i++)
    {
        zbir1=zbir1+(a[i]*veze[i]);
    }
    for(i=1;i<=n;i++)
    {
        zbir2=zbir2+(a[i]*(0-veze[i]));
    }
    if(zbir1>zbir2)
    {
        cout<<zbir1;
    }
    else
    {
        cout<<zbir2;
    }
    return 0;
}