using System;
using System.Linq;
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            int[] a = new int[n];
            int[] x = new int[m];
            int[] y = new int[m];
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
            }
            int[] br = new int[n];
            for (int j = 0; j < m; j++)
            {
                var s1 = Console.ReadLine().Split();
                x[j] = int.Parse(s1[0]);
                y[j] = int.Parse(s1[1]);
            }
            int br1 = 0;
            for (int i = 0; i < n; i++)
            {
                br[i] = 0;
                for (int j = 0; j < m; j++)
                {
                    if ((i + 1) == x[j] || (i + 1) == y[j]) br[i]++;
                }
                if (a[i] > 0) br1++;
            }
            int[] sreca = new int[n];
            int u_sreca = 0;
            if (br1 == n)
            {
                for (int i = 0; i < n; i++)
                {
                    sreca[i] = a[i] * br[i];
                }
                u_sreca = sreca.Sum();
            }
            else if (br1 == 0)
            {
                for (int i = 0; i < n; i++)
                {
                    sreca[i] = a[i] * (-br[i]);
                }
                u_sreca = sreca.Sum();
            }
            Console.WriteLine(u_sreca);
        }
    }