using System;
class Program
{
    static void Main()
    {
        var s = Console.ReadLine().Split();
        int N = int.Parse(s[0]);
        int M = int.Parse(s[1]);
        int[] A = new int[N];
        for (int i = 0; i < N; i++)
            A[i] = int.Parse(Console.ReadLine());
        int[] X = new int[M];
        int[] Y = new int[M];
        int aqu = 0;
        int sum1 = 0;
        int sum2 = 0;
        int temp = 0;
        for (int i = 0; i < M; i++)
        {
            s = Console.ReadLine().Split();
            X[i] = int.Parse(s[0]);
            Y[i] = int.Parse(s[1]);
        }
        int happiness = 0;
        for (int j = 0; j < N; j++)
        {
            temp = j;
            aqu = 0;
            for (int k = 0; k < M; k++)
            {
                if (temp + 1 == X[k])
                    aqu++;
                if (temp + 1 == Y[k])
                    aqu++;
            }
            sum1 = sum1 + A[j] * aqu;
            sum2 = sum2 + A[j] * (0 - aqu);
        }
        happiness = sum1;
        if (happiness < sum2)
            happiness = sum2;
        Console.WriteLine(happiness);
    }
}