#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n,m;
    cin >> n >> m;

    long int a[n];

    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    long long int t1,t2;
    long long int s = 0;

    for(int i = 0; i < m; ++i) {
        cin >> t1 >> t2;
        t1--;
        t2--;
        if((a[t1] > 0 && a[t2] > 0) || (a[t1] > 0 && a[t2] > 0) || (abs(a[t1]) == abs(a[t2]))) {
            s += (a[t1] + a[t2]);
        }
        else {
            s += max(abs(a[t1]),abs(a[t2]));
            s -= min(abs(a[t1]),abs(a[t2]));
        }
    }

    cout << s;

    return 0;
}