using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace takmicenje_2020_1_kolo_2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] st = Console.ReadLine().Split(' ');
            long n = Convert.ToInt64(st[0]);
            long m = Convert.ToInt64(st[1]);
            long s = 0;
            long[] x = new long[n];
            long[] bp = new long[n];
            long[] bn = new long[n];
            for(long i = 0; i < n; i++) x[i] = Convert.ToInt64(Console.ReadLine());
            for(long i = 0;i<m;i++)
            {
                string[] st1 = Console.ReadLine().Split(' ');
                long o1 = Convert.ToInt64(st1[0]) - 1;
                long o2 = Convert.ToInt64(st1[1]) - 1;
                if (x[o1] + x[o2] > 0 || x[o1] > 0 && x[o2] > 0)
                {
                    bp[o1]++;
                    bp[o2]++;
                }
                else
                {
                    bn[o1]++;
                    bn[o2]++;
                }
                
            }
            for (long i = 0; i < n; i++)
            {
                s = s + x[i] * (bp[i] - bn[i]);
            }
            Console.WriteLine(s);




        }
    }
}