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




public class Test
{
    
    public static void process()throws IOException
    {
         int n = ni();
         int m = ni();
         ArrayList<Node> a = new ArrayList<Node>();
         int val[] = new int[n];
         for(int i=0;i<n;i++)
         {
             val[i]=ni();
             Node node = new Node(i,val[i]);
             a.add(node);
         }
         Collections.sort(a, new SortNode());
         int[][] G = new int[n][n];
         int edgeCount[] = new int[n];

         while(m-->0)
         {
              int u = ni();
              int v = ni();
              edgeCount[u-1]++;
              edgeCount[v-1]++;
              G[u-1][v-1] = 1;
              G[v-1][u-1] = 1;
         }
         // for(Node no : a)
         // {
         //      pn(no.in+" "+no.value);
         // }
         boolean removed[] = new boolean[n];
         long cost = 0l;
         for(Node node : a)
         {
               removed[node.in]=true;
               if(edgeCount[node.in]>0)
               {
                    for(int i=0;i<n;i++)
                    {
                         if(G[node.in][i]==1 && !removed[i])
                         {
                              cost+=val[i];
                              edgeCount[node.in]--;
                              edgeCount[i]--;
                         }
                    }
               }
         }
         pn(cost);

      

    }


    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new AnotherReader();
        boolean oj = true;

        // oj = System.getProperty("ONLINE_JUDGE") != null;
        // if(!oj) sc=new AnotherReader(100);

        // long s = System.currentTimeMillis();
        int t=1;
        while(t-->0)
            process();
        out.flush();
        // if(!oj)
        //     System.out.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static boolean multipleTC=false;



/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
class Node
{
     int in, value;
     Node(int x, int y)
     {
          in=x;
          value = y;
     }
}
class SortNode implements Comparator<Node>
{
     public int compare(Node a, Node b)
     {
          return b.value - a.value;
     }
}