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)
        {
            var b = Console.ReadLine().Split();
            int n = int.Parse(b[0]);
            int m = int.Parse(b[1]);
            int[] N = new int[n];
            int[,] M = new int[m,2];
            int[] P = new int[n];
            int[] Neg = new int[n];
            int i, j, s=0;
            for (i = 0; i < n; i++)
            {
                N[i] = int.Parse(Console.ReadLine());
            }
            for (i = 0; i < m; i++)
            {
                b = Console.ReadLine().Split();
                M[i, 0] = int.Parse(b[0]);
                M[i, 1] = int.Parse(b[1]);
            }
            for (i = 0; i < n; i++)
            {
                for (j = 0; j < m; j++)
                {
                    if (M[j, 0] == i + 1)
                    {
                        if((N[i] >= 0 && N[M[j,1]-1] >= 0) || (Math.Abs(N[i]) > Math.Abs(N[M[j, 1] - 1]) && N[i] > N[M[j, 1] - 1]) || (Math.Abs(N[i]) < Math.Abs(N[M[j, 0] - 1]) && N[i] < N[M[j, 0] - 1]))
                        {
                            P[i]++;
                        }
                        else
                        {
                            Neg[i]++;
                        }
                    }
                    else if(M[j, 1] == i + 1)
                    {
                        if ((N[i] >= 0 && N[M[j, 0] - 1] >= 0) || (Math.Abs(N[i]) > Math.Abs(N[M[j, 0] - 1]) && N[i] > N[M[j, 0] - 1]) || (Math.Abs(N[i]) < Math.Abs(N[M[j, 0] - 1]) && N[i] < N[M[j, 0] - 1]))
                        {
                            P[i]++;
                        }
                        else
                        {
                            Neg[i]++;
                        }
                    }
                }
            }
            for (i = 0; i < n; i++)
            {
                s += (N[i] * (P[i] - Neg[i]));
            }
            Console.WriteLine(s);
        }
    }
}