using System;

namespace istinska_sreca
{
    class Program
    {
        // https://youtu.be/dQw4w9WgXcQ
        static void unos(string s, ref int a, ref int b)
        {
            int y = s.IndexOf(" ");
            a += int.Parse(s.Substring(0, y));
            s = s.Substring(y + 1);
            b += int.Parse(s);
        }
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int n = 0, m = 0;
            unos(s, ref n, ref m);
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
            }
            int[,] p = new int[n, n];
            for (int i = 0; i < m; i++)
            {
                string s1 = Console.ReadLine();
                int x1 = -1, x2 = -1;
                unos(s1, ref x1, ref x2);
                if(a[x1]+a[x2]>0)
                {
                    p[x1, x2] = 1;
                    p[x2, x1] = 1;
                }
                else
                {
                    p[x1, x2] = -1;
                    p[x2, x1] = -1;
                }
            }
            int vsr = 0;
            for (int i = 0; i < n; i++)
            {
                int sreca = 0;
                for (int j = 0; j < n; j++)
                {
                    sreca += p[i,j];
                }
                sreca *= a[i];
                vsr += sreca;
            }
            Console.WriteLine(vsr);
        }
    }
}