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

namespace takmicenje2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,m,i,bp=0,bn=0,p,h,ss=0,s=0,f=0;
            string[] nz = Console.ReadLine().Split();
            n = Int32.Parse(nz[0]);
            m = Int32.Parse(nz[1]);
            int[] niz = new int[n+1];
            int[] p1 = new int[m+1];
            int[] p2 = new int[m+1];
            int[] dt= new int[n+1];
            int[] st = new int[n+1];
            string[] u1;
            for (i=1;i<=n;i++)
            {
                niz[i] = int.Parse(Console.ReadLine());
                s += niz[i];
                dt[i] = 0;
                if (niz[i] >= 0)
                    bp++;
                else
                    bn++;
            }
            for (i = 1; i <= m; i++)
            {
                u1= Console.ReadLine().Split();
                p1[i]= Int32.Parse(u1[0]);
                p2[i] = Int32.Parse(u1[1]);
            }
            for (i = 1; i <= m; i++)
            {
                p = p1[i];
                h = p2[i];
                dt[p]++;
                dt[h]++;
            }
            for (i = 1; i < n && f==0; i++)
            {
                if (dt[i] != dt[i + 1])
                    f = 1;
            }
            for (i = 1; i <= n; i++)
                st[i] = dt[i] * niz[i];
            if(bp==n)
            {
                for (i = 1; i <= n; i++)
                    ss+=st[i];
            }
            if (bn == n)
            {
                for (i = 1; i <= n; i++)
                    ss -= st[i];
            }
            if(s>=0 && f==0)
            {
                ss=s;
            }
            if (s < 0 && f == 0)
            {
                ss = -s;
            }
            if(bn!=n || bp!=n || f==1)
            {
                for (i = 1; i <= n; i++)
                    ss += st[i];
                if (ss < 0)
                    ss = -ss;
            }
            Console.WriteLine(ss);
            Console.ReadLine();
        }
    }
}