#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
vector<long> v[100009];
long res=0, res1, res2, n, m, arr[100009], br[100009];
int main() {
FASTIO
cin >> n >> m;
for (int i = 1; i <= n; i++) {
    cin >> arr[i];
}

for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    br[a]++;
    br[b]++;
}

//for (int i = 1; i <= n; i++) {
//    cout << br[i] << " ";
//}

for (int i = 1; i <= n; i++) {
res1+=(arr[i]*(br[i]-0));
res2+=(arr[i]*(0-br[i]));
}
res=max(res1, res2);
cout << res << "\n";

return 0;
}