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.*;
import java.math.BigInteger;
import java.util.*;

/**
 * Created by Alvin on 5/28/2016.
 */

public class Codeforces_round_250_div_2_TheChildAndToy {
    public static void main(String[] args) {
        FScanner input = new FScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out), true);
        int n = input.nextInt();
        int m = input.nextInt();
        int[] cost = new int[n];
        for (int i = 0; i < cost.length; i++) {
            cost[i] = input.nextInt();
        }
        BigInteger total = BigInteger.ZERO;
        for (int i = 0; i < m; i++) {
            int start = input.nextInt() - 1;
            int end = input.nextInt() - 1;
            int weight = Math.min(cost[start], cost[end]);
            total = total.add(BigInteger.valueOf(weight));
        }
        out.println(total);
        out.close();
    }

    static class KruskalMST {
        static HashMap<Integer, ArrayList<Edge>> graph;
        static HashSet<Integer> vertices;
        static ArrayList<Edge> allEdges;

        public static void init() {
            graph = new HashMap<>();
            allEdges = new ArrayList<>();
            vertices = new HashSet<>();
        }

        public static ArrayList<Edge> getMST() {
            ArrayList<Edge> solutionList = new ArrayList<>();
            Collections.sort(allEdges, new Comparator<Edge>() {
                @Override
                public int compare(Edge o1, Edge o2) {
                    return new Integer(o1.weight).compareTo(o2.weight);
                }
            });

            for (int current : vertices) {
                DisjointSet.createSet(current);
            }

            for(Edge currentEdge : allEdges) {

                // Obtain the sets of two vertices of the edge
                int startRoot = DisjointSet.findSet(currentEdge.start);
                int endRoot = DisjointSet.findSet(currentEdge.end);

                // Check if the vertices are in same set or different set
                // If vertices are in same set then ignore the edge
                // Will create a cycle or unnecessary edge
                if(startRoot == endRoot) {
                    continue;
                } else {
                    solutionList.add(currentEdge);
                    DisjointSet.unionSet(currentEdge.start, currentEdge.end);
                }
            }

            return solutionList;
        }

        public static void addEdge(int start, int end, int weight) {
            ArrayList<Edge> list = graph.containsKey(start) ? graph.get(start) : new ArrayList<>();
            Edge currentEdge = new Edge(start, end, weight);
            allEdges.add(currentEdge);
            vertices.add(start);
            vertices.add(end);
            list.add(currentEdge);
            graph.put(start, list);
        }
    }

    static class Edge {
        int start;
        int end;
        int weight;

        public Edge(int s, int e, int weight) {
            this.start = s;
            this.end = e;
            this.weight = weight;
        }
    }

    static class DisjointSet {
        static HashMap<Integer, Node> map = new HashMap<>();

        public static void createSet(int data) {
            Node node = new Node(data, 0);
            node.parent = node;
            map.put(data, node);
        }

        public static int findSet(int data) {
            int parentData = map.get(data).parent.data;
            if (parentData == data) {
                return data;
            } else {
                return findSet(parentData);
            }
        }

        public static boolean unionSet(int firstSet, int secondSet) {
            int firstParentID = findSet(firstSet);
            int secondParentID = findSet(secondSet);
            Node firstParent = map.get(firstParentID);
            Node secondParent = map.get(secondParentID);

            // If they are part of same set do nothing
            if (firstParentID == secondParentID) {
                return false;
            }

            if (firstParent.rank > secondParent.rank) {
                secondParent.parent = firstParent;
            } else if (firstParent.rank < secondParent.rank) {
                firstParent.parent = secondParent;
            } else {
                firstParent.rank++;
                secondParent.parent = firstParent;
            }
            map.put(firstParentID, firstParent);
            map.put(secondParentID, secondParent);

            return true;
        }

        static class Node {
            int data;
            Node parent;
            int rank;

            public Node(int data, int rank) {
                this.data = data;
                this.rank = rank;
            }
        }
    }

    public static PrintWriter out;

    public static class FScanner {
        BufferedReader br;
        StringTokenizer st;

        public FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}

