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

using namespace std;

typedef long long ll;

const ll mxN = 100000;

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[mxN] = 0;
        np[mxN] = 0;
    }
    for(int i = 0 ; i < M; i++)
    {
        ll x,y;
        cin >> x >> y;
        x--;
        y--;
        if(a[x] >= 0 && a[y] >= 0)
        {
            p[x]++;
            p[y]++;
        }
        else if(x < 0 && y < 0)
        {
            np[x]++;
            np[y]++;
        }
        else
        {
            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;
}