#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n , m, s[100001], p[100001] = {};

    cin >> n >> m;

    for (int i = 0 ; i < n ; i++) cin >> s[i];

    for (int i = 0 ; i < m ; i++)
    {
        int a , b;
        cin >> a >> b;
        a--;b--;

        long long res1 = s[a] * (p[a] + 1) + s[b] * (p[b] + 1);
        long long res2 = s[a] * (p[a] - 1) + s[b] * (p[b] - 1);

        if (res1 > res2)
        {
            p[b]++;
            p[a]++;
        }
        else
        {
            p[b]--;
            p[a]--;
        }
    }
    long long res = 0;
    for (int i = 0 ; i < n ; i++)
        res += s[i] * p[i];
    cout << res;

}