#include <bits/stdc++.h>

#define pb push_back
#define ll long long
#define pii pair<int, int>
#define xx first
#define yy second

using namespace std;

ll n, m, a[100010], ress;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    cin>>n>>m;

    for (int i=1; i<=n; i++) cin>>a[i];

    while (m--)
    {
        int x, y; cin>>x>>y;
        if (a[x]>=0 && a[y]>=0)
            ress+=(a[x]+a[y]);
        else if (a[x]<0 && a[y]<0)
        {
            ress-=a[x]; ress-=a[y];
        }
        else
        {
            if (abs(a[x])>=abs(a[y]))
            {
                if (a[x]>=0) ress+=a[x];
                else ress-=a[x];
                if (a[y]>=0) ress-=a[y];
                else ress+=a[y];
            }
            else
            {
                if (a[x]>=0) ress-=a[x];
                else ress+=a[x];
                if (a[y]>=0) ress+=a[y];
                else ress-=a[y];
            }
        }
        //cout<<ress<<endl;
    }

    cout<<ress;

}