#include <bits/stdc++.h>
using namespace std;

#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define inf INT_MAX
#define llinf LLONG_MAX
#define mt make_tuple
#define mp make_pair
#define parll pair<ll,ll>
#define parii pair<int,int>

int main()
{
    ios;

    int n,m;

    cin >> n >> m;
    vector <ll> A(n);
    for ( int i = 0; i < n; i++ )
    {
        cin >> A[i];
    }

    vector <parll> B(n),C(n,mp(0,0));
    for ( int i = 0; i < m; i++ )
    {
        cin >> B[i].first >> B[i].second; B[i].first--; B[i].second--;
    }

    for ( int i = 0; i < m; i++ )
    {
        if ( A[B[i].first] >= 0 && A[B[i].second] >= 0 )
        {
            C[B[i].first].first++;
            C[B[i].second].first++;
        }
        else if ( A[B[i].first] < 0 && A[B[i].second] < 0 )
        {
            C[B[i].first].second++;
            C[B[i].second].second++;
        }
        else if ( A[B[i].first] < 0 && A[B[i].second] >= 0 )
        {
            if ( abs(A[B[i].first]) > A[B[i].second] )
            {
                C[B[i].first].second++;
                C[B[i].second].second++;
            }
            else
            {
                C[B[i].first].first++;
                C[B[i].second].first++;
            }
        }
        else //if ( A[B[i].first] >= 0 && A[B[i].second] < 0 )
        {
            if ( abs(A[B[i].second]) > A[B[i].first] )
            {
                C[B[i].first].second++;
                C[B[i].second].second++;
            }
            else
            {
                C[B[i].first].first++;
                C[B[i].second].first++;
            }
        }
    }

    ll sreca = 0;
    for ( int i = 0; i < n; i++ )
    {
        sreca += A[i]*(C[i].first-C[i].second);
    }

    cout << sreca;

    return 0;
}