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

namespace prijatelji
{
    class Program
    {
        static long sreca(int n, int[] a, int[,] p)
        {
            long s = 0;
            for (int i=0; i< n; i++)
            {
                int k = 0;
                for (int j = 0; j < n; j++) if (p[i, j] != 0) k = k + p[i, j];
                s = s + a[i] * k;
            }
            return s;
        }

        static long brofist(int n, int m, int[] a,int[,] p, int i, int j, int[] m1, int[] m2)
        {
            if (i < m)
            {
                p[m1[i] - 1, m2[i] - 1] = j * p[m1[i] - 1, m2[i] - 1];
                p[m2[i] - 1, m1[i] - 1] = j * p[m2[i] - 1, m1[i] - 1];
                if (j == -1)
                {
                    return Math.Max(sreca(n, a, p), brofist(n, m, a, p, i + 1, 1, m1, m2));
                }
                else return Math.Max(sreca(n, a, p), brofist(n, m, a, p, i, -1, m1, m2));
            }
            else return long.MinValue;
        }

        static void Main(string[] args)
        {
            string[] x = Console.ReadLine().Split();
            int n = int.Parse(x[0]);
            int m = int.Parse(x[1]);
            bool b = true;
            int[] a = new int[n];
            int[] m1 = new int[m];
            int[] m2 = new int[m];
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
                if (a[i] < 0) b = false;
            }
            int[,] p = new int[n, n];
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++) p[i, j] = 0;
            for (int i=0; i< m; i++)
            {
                x = Console.ReadLine().Split();
                int y = int.Parse(x[0]);
                int z = int.Parse(x[1]);
                m1[i] = y;
                m2[i] = z;
                p[y - 1, z - 1] = 1;
                p[z - 1, y - 1] = 1;
            }
            long s = sreca(n, a, p);
            if (!b) s = brofist(n, m, a, p, 0, 1, m1, m2);
            Console.WriteLine(s);
        }
    }
}