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[] s = Console.ReadLine().Split(' ');
            int n= int.Parse (s[0]);
            int m= int.Parse (s[1]);
            long[] a=new long[n];
            long p1 = 0;
            long p2 = 0;
            long[] brpr = new long[n];
            long[] brnpr = new long[n];
            long sreca = 0;
            for(long i=0;i<n;i++)
            {
                a[i] = long.Parse(Console.ReadLine());
            }
            for(long i=0;i<m;i++)
            {
                string[] o = Console.ReadLine().Split(' ');
                p1 = int.Parse(o[0]);
                p2 = int.Parse(o[1]);
                if(a[p1]+a[p2]>0 || a[p1]>0&&a[p2]>0)
                {
                    brpr[p1]++;
                    brpr[p2]++;
                }
                else
                {
                    brnpr[p1]++;
                    brnpr[p2]++;
                }

            }
            for(long i= 0;i<n;i++)
            {
                sreca += a[i] * (brpr[i] - brnpr[i]);
            }
            Console.WriteLine(sreca);
        }
    }
}