#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define fb(i,b,a) for(int i=b;i>=a;i--)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100005;
const int inf = 1e9 + 5;

int n, m;
ll niz[maxn];

int cnt[maxn];

int main()
{
    ios::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
    cin >> n >> m;
    ff(i,1,n)cin >> niz[i];
    ll kol = 0;
    ff(i,1,m){
        int u, v;
        cin >> u >> v;
        cnt[u]++, cnt[v]++;
        if((niz[u] > 0ll && niz[v] > 0ll) || (niz[u] < 0ll && niz[v] < 0ll))continue;
        ll a = abs(niz[u]);
        ll b = abs(niz[v]);
        if(a > b)kol += b;
        else kol += a;
    }
//    cout << endl;
    ll rez = 0ll;
    ff(i,1,n)rez += llabs(niz[i] * cnt[i]);
    rez = rez - 2ll * kol;
    cout << rez << endl;
    return 0;
}
/**
4 3
2 -5 -4 3
1 2
2 3
3 4
**/