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.util.*;
//import java.math.*; // for bigInteger

public class Main {

  static InputReader sc;
  static PrintWriter out;

  public static void main(String args[]) throws Exception {
    sc = new InputReader();
    out = new PrintWriter(System.out);
    int t = 1;  
    //t = sc.nextInt();
    for (int tt = 1; tt <= t; ++tt)
      solve(tt);
    out.close();
  }
  
  static void solve(int t) {
    int n= sc.nextInt(), m = sc.nextInt();
    int[] v = new int[n+1];
    for(int i=1;i<n+1;++i)  v[i]  = sc.nextInt();
    int[][] parts = new int[n+1][n+1];
    for(int i=0;i<m;++i) {
      int x = sc.nextInt(), y = sc.nextInt();
      parts[x][y] = v[y];
      parts[y][x] = v[x];
    } 
    boolean[] done = new boolean[n+1];
    for(int i=1;i<n+1;++i) {
      for(int j=1;j<=n;++j) {
        parts[i][0]+=parts[i][j];
      }
    }
    long answer = 0;
    for(int rep=0;rep<n;++rep) {
      //find biggest v
      int maxI = 0;
      int max = Integer.MIN_VALUE;
      for(int i=1;i<=n;++i) {
        if(!done[i] && v[i]>max)  {
          max = v[i];
          maxI = i;
        }
      }
      // remove maxI
      answer += parts[maxI][0];
      done[maxI] = true;
      for(int i=1;i<=n;++i) {
        parts[i][0] -= parts[i][maxI];
      }
    } 
    out.println(answer);
  } 

  public static class InputReader {
    BufferedReader br;
    StringTokenizer st;

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

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

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

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

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

  /*
   * private final static int m =(int)1e9+7; private static class Pair<T,V> { T
   * first; V second; Pair(final T first, final V second) { this.first = first;
   * this.second = second; } public boolean equals(Object o) { Pair given =
   * (Pair)o; if(given.first == first && given.second == second) return true;
   * return false; } public int hashCode() { long temp =
   * (long)(first.hashCode())*31; temp = (temp+(long)second.hashCode())%m; return
   * (int)temp; } }
   */

  public static void debug(final int[]... var) {
    for (final int[] row : var) {
      debug(row);
    }
  }

  public static void debug(final long[]... var) {
    for (final long[] row : var) {
      debug(row);
    }
  }

  public static void debug(final String[]... var) {
    for (final String[] row : var) {
      debug(row);
    }
  }

  public static void debug(final double[]... var) {
    for (final double[] row : var) {
      debug(row);
    }
  }

  public static void debug(final char[]... var) {
    for (final char[] row : var) {
      debug(row);
    }
  }

  public static void debug(final int... var) {
    for (final int i : var)
      System.err.print(i + " ");
    System.err.println();
  }

  public static void debug(final String... var) {
    for (final String i : var)
      System.err.print(i + " ");
    System.err.println();
  }

  public static void debug(final double... var) {
    for (final double i : var)
      System.err.print(i + " ");
    System.err.println();
  }

  public static void debug(final long... var) {
    for (final long i : var)
      System.err.print(i + " ");
    System.err.println();
  }

  public static void debug(final char... var) {
    for (final char c : var)
      System.err.print(c + " ");
    System.err.println();
  }

  /*
   * public static <T> void debug(T ...varargs) { // Warning // Heap Pollution
   * might occur // this overrides even 1d and 2d array methods as it is an
   * object... // + i am not using object based array like Integer[] // I am using
   * int[] so that is a problem as i need Wrapper class as an argument for(T
   * val:varargs) System.err.printf("%s ",val); System.err.println(); }
   */
}
