#include <bits/stdc++.h>
#define pb push_back
#define sc scanf
#define pr printf
#define tc int t; cin>>t; while(t--)
#define ccout if(debug) cout

typedef long long ll;
using namespace std;
const int mxN=100010,mxM=100010,mod=1e9+7;
int n,m, no[mxN], p[mxN];
ll a[mxN], sol;

struct veza{
   int a, b;
}parovi[mxM];
void unos(){
   sc("%d %d", &n, &m);
   for(int i=1; i<=n; i++)
      sc("%lld", &a[i]);
   for(int i=1; i<=m; i++){
      sc("%d %d", &parovi[i].a, &parovi[i].b);
      no[parovi[i].a]++;
      no[parovi[i].b]++;
   }
}
void solve(){
   ll delta;
   int drugi, prvi;
   for(int i=1; i<=m; i++){
      prvi=parovi[i].a;
      drugi=parovi[i].b;

      delta=2*a[prvi]+2*a[drugi];
      if(delta>0){
         p[prvi]++;
         p[drugi]++;
      }
   }

   for(int i=1; i<=n; i++){
      sol+=(2*p[i]-no[i])*a[i];
   }
}
int main(){
   unos();
   solve();
   cout<<sol<<endl;

   return 0;
}