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

namespace Prijatelji
{
    class Program
    {
        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];
            int[,] b = new int[m, 2];
            int[] k = new int[n];
            long zbir = 0;
            long zbir1 = 0;
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
            }
            for (int i = 0; i < m; i++)
            {
                s = Console.ReadLine().Split();
                int x = int.Parse(s[0]);
                int y = int.Parse(s[1]);
                b[i, 0] = x;
                b[i, 1] = y;
                k[x - 1]++;
                k[y - 1]++;
            }
            for (int i = 0; i < n; i++)
            {
                zbir+=k[i] * a[i];
                zbir1 += -1 * k[i] * a[i];
            }
            long max = Math.Max(zbir, zbir1);
            bool[,] p = new bool[(long)Math.Pow(2, m), m];
            for (long i = 1; i < Math.Pow(2, m); i++)
            {
                for (int j = 0; j < m; j++)
                {
                    if(p[i, j] == false)
                    {
                        p[i, j] = true;
                        
                        if (j!=0)
                        {
                            for (int l = 0; l < j; l++)
                            {
                                p[i, l] = false;
                            }
                        }
                        if (i != Math.Pow(2, m) - 1)
                        {
                            for (int r = 0; r < m; r++)
                            {
                                p[i + 1, r] = p[i, r];
                            }
                        }
                        break;
                    }
                    else if (i != Math.Pow(2, m) - 1)
                    {
                        p[i + 1, j] = p[i, j];
                    }
                }
            }
            for (long i = 0; i < Math.Pow(2,m); i++)
            {
                zbir = 0;
                int[] k1 = new int[n];
                for (int j = 0; j < m; j++)
                {
                    if(p[i,j]==false)
                    {
                        k1[b[j, 0]-1]--;
                        k1[b[j, 1]-1]--;
                    }
                    else if(p[i,j])
                    {
                        k1[b[j, 0]-1]++;
                        k1[b[j, 1]-1]++;
                    }
                }
                for (int j = 0; j < n; j++)
                {
                    zbir += k[j] * a[j];
                }
                max = Math.Max(max, zbir);
            }
            Console.WriteLine(max);
        }
    }
}