using System;
using System.Collections.Generic;
using System.Linq;
public class Program {
    public static void Main() {
        int.TryParse(Console.ReadLine(), out int n);
        int[] pricesOfRed = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        int totalCost = 0;

        for(int i = 0; i < n; i++)
        {
            int[] recipe = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int totalIfUseBlue = pricesOfRed[recipe[0] - 1] + pricesOfRed[recipe[1] - 1];
            int totalIfUseRed = pricesOfRed[i];

            if(totalIfUseBlue < totalIfUseRed)
            {
                //如果利用红色药剂来合成当前蓝色药剂的成本低于只使用红色药剂
                totalCost += totalIfUseBlue;
            }
            else
            {
                //如果利用红色药剂来合成当前蓝色药剂的成本高于只使用红色药剂
                totalCost += totalIfUseRed;
            }
        }
        Console.WriteLine(totalCost);
    }
}