using System;


namespace ConsoleApp1
{
    class Program
    {
        struct parovi
        {
            public int a;
            public int b;
        }
        static void Main(string[] args)
        {
            String[] l = Console.ReadLine().Split();
            int n = int.Parse(l[0]);
            int m = int.Parse(l[1]);
            int[] a = new int[n];
            int[] br = new int[n + 1];
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
            }
            parovi[] w = new parovi[m];
            for (int i = 0; i < m; i++)
            {
                String[] p = Console.ReadLine().Split();
                w[i].a = int.Parse(p[0]);
                w[i].b = int.Parse(p[1]);
                for (int j = 0; j < n; j++)
                {
                    if (w[i].a == j + 1 || w[i].b == j + 1)
                        br[j + 1] += 1;
                }
            }
            int[] s = new int[n];
            int zbir = 0;
            for (int i = 0; i < n; i++)
            {
                if (a[i] < 0)
                {
                    for (int j = 0; j < m; j++)
                    {
                        if (w[j].a == i + 1 || w[j].b == i + 1)
                        {
                            int prvi = w[j].a;
                            int drugi = w[j].b;
                            br[prvi] = br[prvi] * (-1);
                            br[drugi] = br[drugi] * (-1);
                        }
                    }
                }
            }
            for (int i = 0; i < n; i++)
            {
                if(a[i] < 0)
                {
                    if (br[i + 1] > 0)
                        br[i + 1] = br[i + 1] * (-1);
                }
            }
            for (int i = 0; i < n; i++)
            {
                s[i] = a[i] * br[i + 1];
                zbir += s[i];
            }
            Console.WriteLine(zbir);
        }
    }
}