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.io.*;

/*
 * author:yanghui
 */
public class C {

    class FastIO {
        BufferedReader br;
        StringTokenizer st;
        PrintWriter out;

        public FastIO(File in, File o) {
            try {
                br = new BufferedReader(new FileReader(in));
                out = new PrintWriter(new FileWriter(o));
            } catch (Exception e) {
                e.printStackTrace();
            }
            eat("");
        }

        public FastIO() {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(new OutputStreamWriter(System.out));
            eat("");
        }

        public void eat(String s) {
            st = new StringTokenizer(s);
        }

        public String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                throw new IOError(e);
            }
        }

        public boolean hasNext() {
            while (!st.hasMoreTokens()) {
                String s = nextLine();
                if (s == null)
                    return false;
                eat(s);
            }
            return true;
        }

        public String next() {
            hasNext();
            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 void print(String ans) {
            out.print(ans);
            out.flush();
        }

        public void print(int ans) {
            out.print(ans);
            out.flush();
        }

        public void print(long ans) {
            out.print(ans);
            out.flush();
        }

        public void print(double ans) {
            out.print(ans);
            out.flush();
        }

        public void println(String ans) {
            out.println(ans);
            out.flush();
        }

        public void println(int ans) {
            out.println(ans);
            out.flush();
        }

        public void println(long ans) {
            out.println(ans);
            out.flush();
        }

        public void println(double ans) {
            out.println(ans);
            out.flush();
        }

        public void println() {
            println("");
            out.flush();
        }

        public void printf(String arg0, Object... arg1) {
            out.printf(arg0, arg1);
            out.flush();
        }

        public void println(int[] ans) {
            for (int i = 0; i < ans.length; i++)
                print(ans[i] + " ");
            println();
        }

        public void println(long[] ans) {
            for (int i = 0; i < ans.length; i++)
                print(ans[i] + " ");
            println();
        }

        public void println(double[] ans) {
            for (int i = 0; i < ans.length; i++)
                print(ans[i] + " ");
            println();
        }

        public void println(Object... ans) {
            for (Object cur : ans)
                print(cur.toString() + " ");
            println();
        }

        public void println(Object ans[][]) {
            for (int i = 0; i < ans.length; i++) {
                println(ans[i]);
            }
        }

        public void println(int ans[][]) {
            for (int i = 0; i < ans.length; i++) {
                println(ans[i]);
            }
        }

        public void println(long ans[][]) {
            for (int i = 0; i < ans.length; i++) {
                println(ans[i]);
            }
        }

        public void println(double ans[][]) {
            for (int i = 0; i < ans.length; i++) {
                println(ans[i]);
            }
        }

        public void println(List<Object> ans) {
            for (Object i : ans) {
                print(i.toString() + " ");
            }
            println();
        }

        public void close() {
            out.flush();
            out.close();
        }
    }

//  FastIO scan = new FastIO(new File("in"), new File("out"));

     FastIO scan = new FastIO();

    public class point implements Comparable<point>{
        int id;
        int value;
        public point(int id , int value){
            this.id = id;
            this.value = value;
        }
        @Override
        public int compareTo(point p) {
            return p.value - this.value;
        }
    }
    
    public void run() {

        int n = scan.nextInt();
        int m = scan.nextInt();
        point a[] = new point[n+1];
        boolean visit[][] = new boolean[n+1][n+1];
        for(int i = 1 ;i <= n ; i ++){
            for(int j = 1;  j <= n ; j ++){
                visit[i][j] = false;
            }
        }
        ArrayList<point> set[] = new ArrayList[n+1];
        for(int i = 1; i <= n ; i ++){
            set[i] = new ArrayList<point>();
        }
        for(int i = 1 ; i <= n ; i ++){
            a[i] = new point(i,scan.nextInt());
        }
        for(int i = 1 ; i <= m ; i ++){
            int x = scan.nextInt();
            int y = scan.nextInt();
            set[x].add(a[y]);
            set[y].add(a[x]);
        }
        Arrays.sort(a,1,n+1);
        long ans = 0;
        for(int i = 1 ; i <= n ; i ++){
            for(point j : set[a[i].id]){
                if(!visit[a[i].id][j.id]){
                    ans += (long) j .value;
                    visit[a[i].id][j.id] = true;
                    visit[j.id][a[i].id] = true;
                }
            }
        }
        scan.println(ans);
        scan.close();
    }

    public static void main(String args[]) throws Exception {
        new C().run();
    }
}
