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];
            int zbir = 0;
            int 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];
            }
            Console.WriteLine(Math.Max(zbir, zbir1));
        }
    }
}