#include <bits/stdc++.h>

using namespace std;

int main()
{ long long n, m, i, aps, sum, x, y;
  cin>> n>> m;
  vector<long long> veka(n), peka(n);
  for(i=0; i<n; i++)cin>> veka[i];
  for(i=0; i<m; i++)
  { cin>> x>> y;
    aps=veka[x-1]+veka[y-1];
    if(aps>0){peka[x-1]++; peka[y-1]++;}
    else{peka[x-1]--; peka[y-1]--;}
  }
  sum=0;
  for(i=0; i<n; i++)
  { sum+=veka[i]*peka[i];
  }
  cout<< sum;

  return 0;
}