using System;

namespace kv1_z2
{
    class Program
    {
        struct takmicar
        {
            public int druzeljubivost;
            public int proznanstva;
            public int sreca;
        }
        static void sreca(takmicar[] a, int t1, int t2)
        {
            int dr1 = a[t1].druzeljubivost, dr2 = a[t2].druzeljubivost;
            if(dr1 >= 0 && dr2 >= 0)
            {
                a[t1].sreca += dr1;
                a[t2].sreca += dr2;
            }
            else if(dr1 < 0 && dr2 < 0)
            {
                a[t1].sreca += -dr1;
                a[t2].sreca += -dr2;
            }
            else if(dr1 < 0)
            {
                if(Math.Abs(dr1) > Math.Abs(dr2))
                {
                    a[t1].sreca += -dr1;
                    a[t2].sreca += -dr2;
                }
                else
                {
                    a[t1].sreca += dr1;
                    a[t2].sreca += dr2;
                }

            }
            else
            {
                if (Math.Abs(dr2) > Math.Abs(dr1))
                {
                    a[t1].sreca += -dr1;
                    a[t2].sreca += -dr2;
                }
                else
                {
                    a[t1].sreca += dr1;
                    a[t2].sreca += dr2;
                }

            }
        }
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            takmicar[] a = new takmicar[n];
            for (int i = 0; i < n; i++) a[i].druzeljubivost = int.Parse(Console.ReadLine());
                for (int i = 0; i < m; i++) 
            {
                s = Console.ReadLine().Split();
                a[int.Parse(s[0]) - 1].proznanstva++;
                a[int.Parse(s[1]) - 1].proznanstva++;
                sreca(a, int.Parse(s[0]) - 1, int.Parse(s[1]) - 1);
            }
            int usreca = 0;
            for (int i = 0; i < n; i++) usreca += a[i].sreca;
            Console.WriteLine(usreca);
        }
    }
}