#include <bits/stdc++.h>

using namespace std;
pair<int, int> people[100007];
int powern[100007];
int powerfrn[100007];
bool done[100007];
vector<int> graph[100007];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m, f;
    long long sol = 0;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> f;
        powern[i] = f;
        people[i] = {abs(f), i};
    }
    int x, y;
    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        people[x-1].first += 1;
        people[y-1].first += 1;
        graph[x-1].push_back(y-1);
        graph[y-1].push_back(x-1);
    }
    int powr;
    sort(people, people + n);
    for (int i = n-1; i >= 0; i--) {
        powr = powern[people[i].second];

        if (powr < 0) {
            for (int j : graph[people[i].second]) {
                if (!done[j]) {
                    powerfrn[j] -= 1;
                    powerfrn[people[i].second] -= 1;
                }
            }
        } else {
            for (int j : graph[people[i].second]) {
                if (!done[j]) {
                    powerfrn[j] += 1;
                    powerfrn[people[i].second] += 1;
                }
            }
        }
        sol += powr * powerfrn[people[i].second];
        done[people[i].second] = true;
    }
    cout << sol;
    return 0;
}