using System;

namespace Prijatelji
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, m;
            string[] s = (Console.ReadLine()).Split();
            n = int.Parse(s[0]);
            m = int.Parse(s[1]);
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
            }
            int[,] p = new int[m, 2];
            for(int i = 0; i < m; i++)
            {
                string[] s1 = (Console.ReadLine()).Split();
                p[i, 0] = int.Parse(s1[0]);
                p[i, 1] = int.Parse(s1[1]);
            }
            bool[] prij = new bool[m];
            int[] br = new int[n];
            for (int i = 0; i < n; i++)
            {
                br[i] = 0;
            }
            for (int i = 0; i < m; i++)
            {
                prij[i] = prijatelj(a, p, i,br);
            }
            //finalna racunica
            long sum = 0;
            for(int i = 0; i < n; i++)
            {
                sum += br[i] * a[i];
            }
            //ispis
            Console.WriteLine(sum);
        }
        static bool prijatelj(int[] a, int[,] p, int i, int[] br)
        {
            int p1 = p[i,0]-1;
            int p2 = p[i, 1]-1;
            if(a[p1]>0 && a[p2] > 0)
            {
                br[p1]++;
                br[p2]++;
                return true;
            }
            if(a[p1] < 0 && a[p2] < 0)
            {
                br[p1]--;
                br[p2]--;
                return false;
            }
            if(a[p1]<0 && a[p2] > 0)
            {
                if (Math.Abs(a[p1]) > Math.Abs(a[p2]))
                {
                    br[p1]--;
                    br[p2]--;
                    return false;
                }
                else
                {
                    br[p1]++;
                    br[p2]++;
                    return true;
                }
            }
            if(a[p1]>0 && a[p2] < 0)
            {
                if (Math.Abs(a[p1]) >= Math.Abs(a[p2]))
                {
                    br[p1]++;
                    br[p2]++;
                    return true;
                }
                else
                {
                    br[p1]--;
                    br[p2]--;
                    return false;
                }
            }
            //Console.WriteLine("Propustih");
            return false;
        }
    }
}