On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy.

The toy consists of n parts and m ropes. Each rope links two parts, but every pair of parts is linked by at most one rope. To split the toy, the child must remove all its parts. The child can remove a single part at a time, and each remove consume an energy. Let's define an energy value of part i as vi. The child spend vf1 + vf2 + ... + vfk energy for removing part i where f1, f2, ..., fk are the parts that are directly connected to the i-th and haven't been removed.

Help the child to find out, what is the minimum total energy he should spend to remove all n parts.

Input

The first line contains two integers n and m (1 ≤ n ≤ 1000; 0 ≤ m ≤ 2000). The second line contains n integers: v1, v2, ..., vn (0 ≤ vi ≤ 105). Then followed m lines, each line contains two integers xi and yi, representing a rope from part xi to part yi (1 ≤ xi, yi ≤ n; xi ≠ yi).

Consider all the parts are numbered from 1 to n.

Output

Output the minimum total energy the child should spend to remove all n parts of the toy.

Examples

Input

4 3
10 20 30 40
1 4
1 2
2 3


Output

40


Input

4 4
100 100 100 100
1 2
2 3
2 4
3 4


Output

400


Input

7 10
40 10 20 10 20 80 40
1 5
4 7
4 5
5 2
5 7
6 4
1 6
1 3
4 3
1 4


Output

160

Note

One of the optimal sequence of actions in the first sample is:

  * First, remove part 3, cost of the action is 20. 
  * Then, remove part 2, cost of the action is 10. 
  * Next, remove part 4, cost of the action is 10. 
  * At last, remove part 1, cost of the action is 0. 



So the total energy the child paid is 20 + 10 + 10 + 0 = 40, which is the minimum.

In the second sample, the child will spend 400 no matter in what order he will remove the parts.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

/**
 * Created by fangxue.zhang on 2014/6/1.
 */
public class CF_250_div2 {

    public static List<Integer> nodes = new ArrayList<Integer>(1100);

    public static void main(String[] args) throws IOException {

        input.init(System.in);

//        List<String> list = new LinkedList<String>();
//
//        for(int i = 0; i < 4; i++){
//            String str = input.next();
//            list.add(str);
//        }
//
//        int count = 0;
//        int idx = -1;
//        for(int i = 0; i < 4; i++){
//            int len = list.get(i).length() - 2;
//            boolean bingo = true;
//            boolean bingo1 = true;
//            for(int j = 0; j < 4; j++){
//                if(i == j) continue;
//                int len1 = list.get(j).length() - 2;
//                if(len < len1 * 2) bingo = false;
//                if(len * 2 > len1) bingo1 = false;
//            }
//            if(bingo == true || bingo1 == true) {
//                count += 1;
//                idx = i;
//            }
//        }
//        if(count == 0 || count >= 2){
//            System.out.println("C");
//            return;
//        }
//        System.out.println(list.get(idx).substring(0, 1));


//        class Pair{
//            public int a, b;
//
//
//        }
//
//        int sum = input.nextInt();
//        int limit = input.nextInt();
//
//        List<Integer> list=  new LinkedList<Integer>();
//
//        for(int i = limit; i >= 1; i--){
//
//            System.out.println(getLowBit(i));
//
//            Pair pair = new Pair();
//
//
//
//
//        }


        int n = input.nextInt();
        int m = input.nextInt();


        List<Integer> order = new ArrayList<Integer>(1100);
        List<List<Integer>> mat = new ArrayList<List<Integer>>(1100);


        for(int i = 0; i < n; i++){
            int x = input.nextInt();
            nodes.add(x);
            order.add(i);
            mat.add(new LinkedList<Integer>());
        }



        for(int i = 0; i < m; i++){
            int a = input.nextInt() - 1;
            int b = input.nextInt() - 1;
            mat.get(a).add(b);
            mat.get(b).add(a);
        }

//        System.out.println(mat);

        ComparatorUser comparator=new ComparatorUser();

        Collections.sort(order, comparator);

//        System.out.println(order);
        Integer res = 0;

        for(int i = n - 1; i >= 0; i--){
            int x = order.get(i);
//            System.out.println(res);
            for(Integer idx : mat.get(x)){
                res += nodes.get(idx);
            }
//            nodes.add(x, 0);
            nodes.set(x, 0);
//            System.out.println(nodes);
        }

//        System.out.println("==========");

        System.out.println(res);





    }

    public static class ComparatorUser implements Comparator {

        public int compare(Object arg0, Object arg1) {
            Integer a=(Integer)arg0;
            Integer b=(Integer)arg1;

            return  nodes.get(a).compareTo(nodes.get(b));
        }

    }

    public static Integer getLowBit(Integer x){
        Integer res = 1;
        while(x % 2 == 0){
            res *= 2;
            x /= 2;
        }
        return res;
    }












    public static class input {
        static BufferedReader reader;
        static StringTokenizer tokenizer;

        /** call this method to initialize reader for InputStream */
        static void init(InputStream input) {
            reader = new BufferedReader(
                    new InputStreamReader(input) );
            tokenizer = new StringTokenizer("");
        }

        /** get next word */
        static String next() throws IOException {
            while ( ! tokenizer.hasMoreTokens() ) {
                //TODO add check for eof if necessary
                tokenizer = new StringTokenizer(
                        reader.readLine() );
            }
            return tokenizer.nextToken();
        }

        static int nextInt() throws IOException {
            return Integer.parseInt( next() );
        }

        static double nextDouble() throws IOException {
            return Double.parseDouble( next() );
        }
        static long nextLong() throws IOException {
            return Long.parseLong( next() );
        }
    }
}
