#include <iostream>
#include <cmath>


using namespace std;

int main()
{
    int n,m;cin>>n>>m;
    int A[n],A1[n],B[n][m];
    for (int i=0;i<n;i++)
    {
        cin>>A[i];
        A1[i]=0;
    }
    for (int i=0;i<m;i++)
    {
        for (int j=0;j<2;j++)
        {
            cin>>B[i][j];
        }
    }
    int countout,p=1,hmst,shrug;
    for (int j=0;j<m*2;j++)
    {
        countout=p;
        for (int k=0;k<m;k++)
        {
            for (int g=0;g<1;g++)
            {
                hmst=B[k][0];
                shrug=B[k][1];
                if (countout==B[k][g])
                {
                    if (A[hmst-1]<0 || A[shrug-1]<0)
                    {
                        A1[hmst-1]--;A1[shrug-1]--;
                    }
                    else if (A[hmst-1]>=0 || A[shrug-1]>=0)
                    {
                        A1[hmst-1]++;A1[shrug-1]++;
                    }
                }
            }
        }
        p++;
    }
    int S=0;
    for (int i=0;i<n;i++)
    {
        S+=(A[i]*A1[i]);
    }
    cout<<S;
    return 0;
}