#include <bits/stdc++.h>
#define mod 998244353
#define ll long long
#define ull unsigned long long
#define inf 1e15
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define pii pair<int,int>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define rall(a) a.begin(),a.end(),greater<int>()
using namespace std;
#define maxn 100005
ll a[maxn];
ll n,m;
ll x,y;
int main(){
	ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
    cin >> n >> m;
    for(int i = 1;i<=n;i++){
        cin >> a[i];
    }
    ll ans = 0;
    for(int i = 0;i<m;i++){
        cin >> x >> y;
        if(a[x]>=0&&a[y]>=0){
            ans+=a[x];
            ans+=a[y];
        }else if(a[x]<=0&&a[y]<=0){
            ans-=a[x];
            ans-=a[y];
        }else{
            if(a[x]>a[y]){
                if(abs(a[x])>abs(a[y])){
                    ans+=a[x];
                    ans+=a[y];
                }else{
                    ans-=a[x];
                    ans-=a[y];
                }
            }else{
                if(abs(a[x])>abs(a[y])){
                    ans-=a[x];
                    ans-=a[y];
                }else{
                    ans+=a[x];
                    ans+=a[y];
                }
            }
        }
    }
    cout<<ans<<"\n";
    return 0;
}