using System;
using System.Collections;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int N, M, OverallHapiness = 0;

        string[] NM = Console.ReadLine().Split();
        N = Convert.ToInt32(NM[0]);
        M = Convert.ToInt32(NM[1]);

        if (N < 0 || N > 100000)
            Console.WriteLine("N < 0 ili N > 100000");
        Ucenik[] U = new Ucenik[N];

        if (M < 0 || M > 100000)
            Console.WriteLine("M < 0 ili M > 100000");
        int[] X = new int[M];
        int[] Y = new int[M];

        for (int i = 0; i < N; i++)
        {
            Ucenik u = new Ucenik();
            u.A = Convert.ToInt32(Console.ReadLine());
            if (u.A < -Math.Pow(10, 9) || u.A > Math.Pow(10, 9))
            {
                Console.WriteLine("Pogresan unos");
                break;
            }
            U[i] = u;
        }

        for (int i = 0; i < M; i++)
        {
            string[] XY = Console.ReadLine().Split();
            X[i] = Convert.ToInt32(XY[0])-1;
            Y[i] = Convert.ToInt32(XY[1])-1;
            if (X[i] == Y[i])
            {
                Console.WriteLine("Pogresan unos");
                break;
            }
        }

        for (int i = 0; i < M; i++)
        {
            for (int j = i-1; j > 0; j--)
            {
                if (X[j] == X[i] && Y[j] == Y[i])
                {
                    Console.WriteLine("Ne moze");
                    break;
                }
            }
        }

        for(int i = 0; i < M; i++)
        {
            if ((U[X[i]].A < 0) && (Math.Abs(U[Y[i]].A) <= Math.Abs(U[X[i]].A)))
            {
                U[X[i]].Enemies++;
                U[Y[i]].Enemies++;
                continue;
            }

            else if ((U[X[i]].A >= 0) && (Math.Abs(U[Y[i]].A) <= Math.Abs(U[X[i]].A)))
            {
                U[X[i]].Friends++;
                U[Y[i]].Friends++;
                continue;
            }

            else if ((U[Y[i]].A < 0) && (Math.Abs(U[X[i]].A) <= Math.Abs(U[Y[i]].A)))
            {
                U[X[i]].Enemies++;
                U[Y[i]].Enemies++;
                continue;
            }

            else if ((U[Y[i]].A >= 0) && (Math.Abs(U[X[i]].A) <= Math.Abs(U[Y[i]].A)))
            {
                U[X[i]].Friends++;
                U[Y[i]].Friends++;
                continue;
            }
        }

        for (int i = 0; i < N; i++)
        {
            U[i].HappinessCalc();
            OverallHapiness += U[i].Happiness;
        }

        Console.WriteLine(OverallHapiness);
    }
}

class Ucenik
{
    public int A, Friends = 0, Enemies = 0, Happiness;
    public void HappinessCalc()
    {
        Happiness = A * (Friends - Enemies);
    }
}