using System;
using System.Linq;

namespace peepeepoopoo
{
    class prijatelji
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int m = Convert.ToInt32(Console.ReadLine());
            int[] N = new int[n];
            int[] M = new int[2 * m];
            for (int i = 0; i < n; i++)
            {
                int input = Convert.ToInt32(Console.ReadLine());
                N[i] = input;
            }
            for (int i = 0; i < 2 * m; i++)
            {
                int input = Convert.ToInt32(Console.ReadLine());
                M[i] = input;
            }
            int[] maxP = new int[n];
            int[] maxN = new int[n];
            int[] poz = new int[n];
            int[] neg = new int[n];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < 2 * m; j++)
                {
                    if (i + 1 == M[j])
                    {
                        poz[i] += 1;
                        neg[i] -= 1;
                    }
                }
            }
            for (int i = 0; i < n; i++)
            {
                maxP[i] = N[i] * poz[i];
                maxN[i] = N[i] * neg[i];
            }
            if (maxP.Sum() > maxN.Sum())
                Console.WriteLine(maxP.Sum());
            else
                Console.WriteLine(maxN.Sum());

        }
    }
}