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.util.*;
import java.lang.*;
import java.io.*;
public  class Solution{
    public static void main(String[] args) {
        InputReader fi=new InputReader(System.in);
        int i,j,n,m;
        n=fi.nextInt();
        m=fi.nextInt();
        long [] x=new long[n+1];
        for (i=1;i<=n;i++)
            x[i]=fi.nextLong();

        Graph g=new Graph(n,m,x);
        for (i=0;i<m;i++)
            g.addEdge(fi.nextInt(),fi.nextInt());

        boolean vis[]=new boolean[n+1];
        long ans=0;
        PriorityQueue<Node> pq=new PriorityQueue<Node>();
        for (i=1;i<=n;i++){
            pq.add(new Node(i,(x[i])));
        }
        while (!pq.isEmpty()){
            Node temp=pq.poll();
            int vertex=temp.vertex;
            if (!vis[vertex]){
             //   System.out.println(" vertex " +vertex + " cost " +temp.cost);
                ans+=g.cost[vertex];
                //System.out.println(" vertex " +vertex);
                for (i=1;i<=n;i++){
                   if (g.adj[i].contains(vertex) && i!=vertex){
                       g.adj[i].remove(new Integer(vertex));
                       g.cost[i]-=x[vertex];
                      // System.out.println(" i = " + i );
                      // print(pq);
                       pq.remove(new Node(i,0));
                       pq.add(new Node(i,(x[i])));
                     //  print(pq);
                   }
                }
                vis[vertex]=true;
            }
        }
        System.out.println(ans);
    }

    static  void print(PriorityQueue<Node> x){
        Iterator<Node> it;
        it=x.iterator();
        while (it.hasNext()){
            System.out.print(it.next().vertex + " ");
        }
        System.out.println();
    }
}
class Graph{
    int n,m;
    ArrayList<Integer> adj[];
    long cost[];
    long energy[];
    Graph(int n,int m,long [] x){
        this.n=n;
        this.m=m;
        cost=new long[n+1];
        adj=new ArrayList[n+1];
        energy=x;
        for (int i=0;i<=n ;i++ ) {
            adj[i]=new ArrayList<Integer>();
        }
    }
    void addEdge(int i,int j){
        adj[i].add(j);
        adj[j].add(i);
        cost[i]=cost[i]+energy[j];
        cost[j]=cost[j]+energy[i];
    }
}

class Node implements Comparable<Node>{
    int vertex;
    long cost;
    Node(int vertex, long  cost){
        this.vertex = vertex; this.cost = cost;
    }

    public int compareTo(Node x){
        return Long.compare(x.cost, this.cost);
    }

    @Override
    public boolean equals(Object o){
        if(o instanceof Node){
            Node c = (Node)o;
            return vertex==c.vertex;
        }
        return false;
    }
}






class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int snext() {
        if (snumChars == -1)
            throw new InputMismatchException();
        if (curChar >= snumChars) {
            curChar = 0;
            try {
                snumChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (snumChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = snext();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = snext();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long nextLong() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = snext();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = snext();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public int[] nextIntArray(int n) {
        int a[] = new int[n+1];
        for (int i = 1; i <= n; i++)
            a[i] = nextInt();
        return a;
    }

    public String readString() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = snext();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}
