#include <iostream>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll mxN = 100010;

ll a[mxN];

ll p[mxN];
ll np[mxN];

int main()
{
    ll N, M;
    cin >> N >> M;
    for(int i = 0; i < N; i++)
    {
        cin >> a[i];
        p[i] = 0;
        np[i] = 0;
    }
    for(int i = 0; i < M; i++)
    {
        ll x,y;
        cin >> x >> y;
        x--;
        y--;
        if(a[x] >= a[y])
        {
            if(a[x] >= abs(a[y]))
            {
                p[x]++;
                p[y]++;
            }
            else
            {
                np[x]++;
                np[y]++;
            }
        }
        else
        {
            if(a[y] > abs(a[x]))
            {
                p[x]++;
                p[y]++;
            }
            else
            {
                np[x]++;
                np[y]++;
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < N; i++)
    {
        ans += a[i] * (p[i] - np[i]);
    }
    cout << ans;
}