#include <bits/stdc++.h>
#define MAXN 100'010
using namespace std;

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

    int n, m;
    cin >> n >> m;
    int a[MAXN];
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    int x[MAXN], y[MAXN];
    for (int i = 0; i < m; i++)
        cin >> x[i] >> y[i];
    static int p[MAXN];
    for (int i = 0; i < m; i++)
    {
        if (abs(a[x[i]]) > abs(a[y[i]]))
        {
            if (a[x[i]] > 0) {p[x[i]]++; p[y[i]]++;}
            else {p[x[i]]--; p[y[i]]--;}
        }
        else
        {
            if (a[y[i]] > 0)  {p[x[i]]++; p[y[i]]++;}
            else {p[x[i]]--; p[y[i]]--;}
        }
    }
    long long sum{};
    for (int i = 1; i <= n; i++)
    {
        sum += a[i] * p[i];
    }
    cout << sum;
    return 0;
}