using System;

namespace Prijatelji
{
    class Program
    {
        #region Ispisi Matricu
        static void Ispisi_Matricu(int[,] mat)
        {
            Console.WriteLine();
            for (int i = 0; i < mat.GetLength(0); i++)
            {
                for (int j = 0; j < mat.GetLength(1); j++)
                {
                    Console.Write(mat[i, j] + " ");
                }
                Console.WriteLine();
            }
        }
        #endregion
        #region Prijateljstvo
        static int[,] Prijateljstvo(int[,] matrix3, int[] niz, int[,]matrix2)
        {
            for (int i = 0; i < matrix3.GetLength(0); i++)
            {
                int a = niz[matrix3[i, 0] - 1];
                int b = niz[matrix3[i, 1] - 1];
                if (a > 0 && b > 0)
                {
                    matrix2[matrix3[i, 0] - 1, 0]++;
                    matrix2[matrix3[i, 1] - 1, 0]++;
                }
                if (a < 0 && b < 0)
                {
                    matrix2[matrix3[i, 0] - 1, 1]++;
                    matrix2[matrix3[i, 1] - 1, 1]++;
                }
                if (a > 0 && b < 0)
                {
                    if (a > Math.Abs(b) || a == Math.Abs(b))
                    {
                        matrix2[matrix3[i, 0] - 1, 0]++;
                        matrix2[matrix3[i, 1] - 1, 0]++;
                    }
                    else
                    {
                        matrix2[matrix3[i, 0] - 1, 1]++;
                        matrix2[matrix3[i, 1] - 1, 1]++;
                    }
                }
                if (a < 0 && b > 0)
                {
                    if (b > Math.Abs(a) || b == Math.Abs(a))
                    {
                        matrix2[matrix3[i, 0] - 1, 0]++;
                        matrix2[matrix3[i, 1] - 1, 0]++;
                    }
                    else
                    {
                        matrix2[matrix3[i, 0] - 1, 1]++;
                        matrix2[matrix3[i, 1] - 1, 1]++;
                    }
                }
            }
            return matrix2;
        }
        #endregion
        #region Brisi_Red
        static int[,] Brisi_Red(int[,] mat, int x)
        {
            for (int i = x; i < mat.GetLength(0); i++)
            {
                if (i < mat.GetLength(0)-1)
                {
                    mat[i, 0] = mat[i + 1, 0];
                    mat[i, 1] = mat[i + 1, 1];
                }
            }
            int[,] mat1 = new int[mat.GetLength(0)-1, 2];
            for (int i = 0; i < mat.GetLength(0)-1; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    mat1[i, j] = mat[i, j];
                }
            }
            return mat1;
        }
        #endregion
        static void Main(string[] args)
        {
            #region Unos
            int s = 0;
            string[] unos = Console.ReadLine().Split();
            int n = Convert.ToInt32(unos[0]);
            int m = Convert.ToInt32(unos[1]);
            int[] niz = new int[n];
            for (int i = 0; i < n; i++)
            {
                niz[i] = int.Parse(Console.ReadLine());
            }
            #endregion
            #region Mat
            int[,] mat = new int[m, 2];
            for (int i = 0; i < m; i++)
            {
                string[] unos1 = Console.ReadLine().Split();
                mat[i, 0] = Convert.ToInt32(unos1[0]);
                mat[i, 1] = Convert.ToInt32(unos1[1]);
            }
            #endregion
            #region Matrix1
            int[,] matrix1 = new int[n, 2];
            for (int i = 0; i < n; i++)
            {
                matrix1[i, 0] = niz[i];
            }
            for (int i = 0; i < n; i++)
            {
                s = 0;
                for (int j = 0; j < m; j++)
                {
                    for (int z = 0; z < 2; z++)
                    {
                        if (mat[j, z] == i + 1) s++;
                    }
                }
                matrix1[i, 1] = s;
            }
            #endregion
            int[,] matrix2 = new int[n, 2];
            #region Matrix3
            int brojac = 0;
            for (int i = 0; i < n; i++)
            {
                brojac = 0;
                int[,] matrix3 = new int[matrix1[i, 1], 2];
                if (matrix1[i, 1] > 0)
                {
                    for (int x = 0; x < m; x++)
                    {
                        if (mat.GetLength(0) > x)
                        {
                            if (mat[brojac, 0] == i + 1 || mat[brojac, 1] == i + 1)
                            {
                                matrix3[brojac, 0] = mat[x, 0];
                                matrix3[brojac, 1] = mat[x, 1];
                                brojac++;
                                matrix1[matrix3[x, 0] - 1, 1]--;
                                matrix1[matrix3[x, 1] - 1, 1]--;
                            }
                        }
                    }
                }
                int counter = 0;
                if (mat != null)
                {
                    for (int j = 0; j < mat.GetLength(0); j++)
                    {
                        if (mat[counter, 0] == matrix3[j, 0] && mat[counter, 1] == matrix3[j, 1])
                        {
                            mat = Brisi_Red(mat, counter);
                            counter = 0;
                        }
                        else
                        {
                            counter++;
                        }
                    }
                }
                matrix2 = Prijateljstvo(matrix3, niz, matrix2);
            }
            #endregion
            int suma = 0;
            for (int i = 0; i < n; i++)
            {
                suma += niz[i] * (matrix2[i, 0] - matrix2[i, 1]);
            }
            Console.WriteLine(suma);
        }
    }
}