#include <stdlib.h>
#include <stdio.h>

long ABS (long X)
{
    if (X>=0)
        return X;
    else
        return -X;
}

int main()
{
    long N, M;
    scanf ("%ld%ld", &N, &M);
    long A[N];
    for (long i=0; i<N; i++)
        scanf ("%ld", &A[i]);

    long long S = 0;
    long X, Y;
    for (long i=0; i<M; i++)
    {
        scanf ("%ld", &X, &Y);
        if (A[X-1] && A[Y-1]>0)
            S += A[X-1] + A[Y-1];
        else if (A[X-1]<0 && A[Y-1]<0)
            S -= A[X-1] + A[Y-1];
        else
            S += ABS (A[X-1] - A[Y-1]);
    }

    printf ("%lld", &S);

    return 0;
}