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

#define sp ' '
#define ar array
#define fi first
#define se second
#define vt vector
#define ends "\n"
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const long long MOD=1e9+7;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void DBG() {
	cerr << "]" << endl;
}
template<class H, class... T> void DBG(H h, T... t) {
	cerr << to_string(h);
	if(sizeof...(t))
		cerr << ", ";
	DBG(t...);
}
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

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


    int N, M; cin >> N >> M;
    vector<ll> A(N);for(auto&a:A) cin >> a;
    vector<pair<int, int>> p;
    vector<pair<int, int>> ev(N, {0, 0});
    for(int i=0; i<M; ++i){
        int X, Y; cin >> X >> Y, --X, --Y;
        p.pb({X, Y});
    }

    for(int i=0; i<M; ++i){
        int X=p[i].fi, Y=p[i].se;
        if(A[X]>=0&&A[Y]>=0){
            ++ev[X].fi, ++ev[Y].fi;
        }else if(A[X]<=0&&A[Y]<=0){
            ++ev[X].se, ++ev[Y].se;
        }else{
            int mn=min(A[X], A[Y]), mx=max(A[X], A[Y]);
            if(abs(mn)>mx)++ev[X].se, ++ev[Y].se;
            else ++ev[X].fi, ++ev[Y].fi;
        }
    }
    ll ans=0;
    for(int i=0; i<N; ++i){
        ans+=A[i]*((ll)(ev[i].fi-ev[i].se));
        //dbg(ev[i].fi, ev[i].se);
    }
    cout << ans << ends;

}