using System;

namespace Minimalan_trud
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, m, max = 0, max1=0, max2=0;
            bool t = true;
            string[] p = Console.ReadLine().Split();
            n = Convert.ToInt32(p[0]);
            m = Convert.ToInt32(p[1]);
            int[] a = new int[n];
            int[] b = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = Convert.ToInt32(Console.ReadLine());
                if (a[i] != 1)
                    t = false;
            }
            for (int i = 0; i < m; i++)
            {
                p = Console.ReadLine().Split();
                b[Convert.ToInt32(p[0]) - 1] += 1;
                b[Convert.ToInt32(p[1]) - 1] += 1;
            }
            if (t)
            {
                for (int i = 0; i < n; i++)
                    max += b[i];
            }
            else
            {
                for (int i = 0; i < n; i++)
                {
                    max1 += a[i] * b[i];
                    max2 += a[i] * b[i] * (-1);
                }
                if (max1 > max2)
                    max = max1;
                else
                    max = max2;
            }
            Console.WriteLine(max);
        }
    }
}