#include <bits/stdc++.h>

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    bool c[N+1][N+1];
    int A[N], x, u = 0, y, br[N];
    for (int i = 0; i <= N; i++)
    {
        for (int j = 0; j <= N; j++)
            c [i][j] = false;
    }
    for (int i = 0; i < N; i++)
        cin >> A[i];
    for (int i = 0; i < N; i++)
        br[i] = 0;
    for (int i = 0; i < M; i++)
    {
            cin >> x >> y;
            c[x-1][y-1] = true;
            br[x-1]++;
            br[y-1]++;
    }
    for (int i = 0; i < N; i++)
    {
        if (A[i] < 0)
        {
            int neg = br[i]%2+1;
            for (int j = 1; j <= N; j++)
            {
                if (neg == 0)
                    break;
                else if (c[i][j])
                {
                    br[i]--;
                    br[j]--;
                }
            }
        }
    }
    for (int i = 0; i < N; i++)
        u+=A[i]*br[i];
    cout<<abs(u);
}