using System;
using System.IO;

namespace feladat2
{
	class Program
	{
		public static void Main(string[] args)
		{
			string[] NMstring;
			string input = Console.ReadLine();
			NMstring = input.Split(' ');
			int N = Convert.ToInt32(NMstring[0]);
			int M = Convert.ToInt32(NMstring[1]);
			int[] kedv = new int[N];
			int[] ismer = new int[2*M]; 
			
			for (int i = 0; i < N; i++) {
				kedv[i] = Convert.ToInt32(Console.ReadLine());
			}
			
			for (int i = 0; i < 2*M; i+=2) {
				string ismerString = Console.ReadLine();
				string[] stringTomb = ismerString.Split(' ');
				ismer[i] = Convert.ToInt32(stringTomb[0]);
				ismer[i+1] = Convert.ToInt32(stringTomb[1]);
			}
			
			int[] dbBarat = new int[9]{0,0,0,0,0,0,0,0,0};
			for (int i = 0; i < 2*M; i++)
				switch (ismer[i]) {
				case 1:
					dbBarat[0]++;
					break;
				case 2:
					dbBarat[1]++;
					break;
				case 3:
					dbBarat[2]++;
					break;
				case 4:
					dbBarat[3]++;
					break;
				case 5:
					dbBarat[4]++;
					break;
				case 6:
					dbBarat[5]++;
					break;
				case 7:
					dbBarat[6]++;
					break;
				case 8:
					dbBarat[7]++;
					break;
				case 9:
					dbBarat[8]++;
					break;
			}
			
			int sum = 0;
			for (int i = 0; i < N; i++) {
				sum += kedv[i] * dbBarat[i];
			}
			
			Console.Write(Math.Abs(sum));
		}
	}
}