#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define endl "\n"

using namespace std;

void solve()
{
    int n,m; cin >> n >> m;

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

    ll ans=0;

    while(m--) {
        int x,y; cin >> x >> y;
        x--; y--;
        if(!a[x])
            ans+=abs(a[y]);
        else if(!a[y])
            ans+=abs(a[x]);
        else if(a[x]<0 && a[y]<0)
            ans+=(-1*a[x])+(-1*a[y]);
        else if(a[x]>0 && a[y]>0)
            ans+=a[x]+a[y];
        else
            ans+=abs(a[x]+a[y]);
    }

    cout << ans << endl;
}

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

    int t=1; //cin >> t;
    while(t--)
        solve();

    return 0;
}