using System;
using System.Linq;

namespace petlja
{
    class Zadatak2
    {
        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[] maxP1 = new int[n];
            int[] maxP2 = new int[n];
            int[] maxN = new int[n];
            int[] tempP = new int[n];
            int[] tempN = new int[n];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < 2 * m; j++)
                {
                    if (i + 1 == M[j])
                    {
                        tempP[i] += 1;
                        tempN[i] -= 1;
                    }
                }
            }
            for (int i = 0; i < n; i++)
            {
                maxP[i] = N[i] * tempP[i];
                maxN[i] = N[i] * tempN[i];
                
            }
            if (maxP.Sum() > maxN.Sum())
                Console.WriteLine(maxP.Sum());
            
            else
                Console.WriteLine(maxN.Sum());

        }
    }
}