#include <bits/stdc++.h>
using namespace std;

#define ll long long

ll n, m;
ll a[100005];

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

    cin >> n >> m;

    for(ll i = 1; i <= n; ++i){
        cin >> a[i];
    }

    ll res = 0;
    for(ll i = 0; i < m; ++i){
        ll x, y;
        cin >> x >> y;

        ll z;
        if(abs(a[x]) >= abs(a[y])){
            z = (a[x] >= 0 ? 1 : -1);
        }
        else{
            z = (a[y] >= 0 ? 1 : -1);
        }

        res += (a[x] + a[y]) * z;
    }

    cout << res << "\n";

    return 0;
}