using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void resi(int[] a, int[,] b, int[] brp, int n, int m, ref int br, ref long sum)
        {
            int[] xd = new int[n];
            int max = 0;
            int index = 0;
            for (int i = 0; i < n; i++)
            {
                xd[i] = Math.Abs(brp[i] * a[i]);
                if (xd[i] > max)
                {
                    max = xd[i];
                    index = i;
                }
            }
            int znak = 0;
            if (a[index] > 0) znak = 1;
            else znak = -1;
            sum = sum + xd[index];
            for (int i=0; i<m; i++)
            {
                if (b[i, 0] == index)
                {
                    sum = sum +znak * a[b[i, 1]];
                    brp[b[i, 1]]--;
                    br--;
                }
                if (b[i,1]==index)
                {
                    sum = sum + znak * a[b[i, 0]];
                    brp[b[i, 0]]--;
                    br--;
                }
            }
            a[index] = 0;
            brp[index] = 0;
        }
        static int resi1(int[] a, int[] brp)
        {
            int sum = 0;
            for (int i = 0; i < a.Length; i++)
                sum = sum + a[i] * brp[i];
            return sum;
        }
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            int[] a = new int[n];
            long sum = 0;
            int br = 0;
            int[,] b = new int[m, 2];
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
                if (a[i] < 0) br++;
            }
            for (int i=0; i<m; i++)
            {
                s = Console.ReadLine().Split(' ');
                b[i, 0] = int.Parse(s[0]) - 1;
                b[i, 1] = int.Parse(s[1]) - 1;
            }
            int[] brp = new int[n];
            for (int i = 0; i < n; i++)
                brp[i] = 0;
            for (int i = 0; i < m; i++)
            {
                brp[b[i, 0]]++;
                brp[b[i, 1]]++;
            }
            if (br == 0) sum = resi1(a, brp);
            else
            {
                br = m;
                while (br>=0)
                {
                    resi(a, b, brp, n, m, ref br, ref sum);
                }
            }
            Console.WriteLine(sum);
        }
    }
}