#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define s second
#define f first

const int MAX_N = 10e5+5;

ll n, m, x, y, ans;
pll a[MAX_N];
set<pll> g[MAX_N];

bool cmp(pll a, pll b){
  return abs(a.f) > abs(b.f);
}

int main(){
  cin >> n >> m;
  for(int i = 0; i < n; ++i){
    cin >> x;
    a[i] = {x, i};
  }
  for(int i = 0; i < m; ++i){
    cin >> x >> y;
    --x;--y;
    g[x].insert(make_pair(y, 0LL));
    g[y].insert(make_pair(x, 0LL));
  }
  sort(a, a + n, cmp);
  for(int i = 0; i < n; ++i){
    for(auto itr = g[a[i].s].begin(); itr != g[a[i].s].end(); ++itr){
        pll h = *itr;
        if(h.s == 0){
            if(a[i].f > 0){
              auto it = g[h.f].find({a[i].s, 0LL});
              g[h.f].erase(it);
              g[h.f].insert({a[i].s, 1LL});
              g[a[i].s].erase(itr);
              g[a[i].s].insert({h.f, 1LL});
            }
            else{
              auto it = g[h.f].find({a[i].s, 0LL});
              g[h.f].erase(it);
              g[h.f].insert({a[i].s, -1LL});
              g[a[i].s].erase(itr);
              g[a[i].s].insert({h.f, -1LL});
            }
        }
    }
  }
  /*for(int i = 0 ; i < n; ++i){
    cout << a[i].s << " : ";
    for(auto x : g[a[i].s]){cout << " ( " << x.f << "," << x.s << ") ";}
    cout << endl;
  }*/
  ans = 0;
  for(int i = 0 ; i < n; ++i){
    for(auto x : g[a[i].s]){ans += a[i].f * x.s;}
  }
  cout << ans << endl;
  return 0;
}