using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace ConsoleApp75
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine()); 
            int m = int.Parse(Console.ReadLine()); 
            int[,] a = new int[n+1,2];
            int[,] b = new int[m,2];
            for (int i = 1; i < n+1; i++) {
                a[i,0] = int.Parse(Console.ReadLine());
              
            }
            for (int i = 0; i < m; i++)
            {
                int x1 = int.Parse(Console.ReadLine());
                int x2 = int.Parse(Console.ReadLine());
                b[i, 0] = x1;
                b[i,1] = x2;
                a[x1, 1]++;
                a[x2, 1]++;


            }
            int r = 0;
            for (int i = 0; i < m; i++)
            {
                odrediPrijatelje(b[i, 0], b[i, 1], ref a);

            }
            for (int i = 1; i < n+1; i++) {
                r +=a[i,0]*a[i,1];
            
            }
            Console.WriteLine(r);
      

        }
        static void odrediPrijatelje(int x,int y,ref int[,] a) {
            int s1 = a[x, 0] * a[x, 1] + a[y, 0] * a[y, 1];
            int s2 = a[x, 0] * (a[x, 1]-2) + a[y, 0] * (a[y, 1]-2);
            if (s2 >= s1)
            {
                a[y, 1] -= 2;
                a[x, 1] -= 2;
                
            }           
            
        }


    }
}