import java.util.Scanner;
public class Prijatelji {
  
    public static long[] unosDruzeljubivosti(int br){
        Scanner sc = new Scanner(System.in);
        long a[] = new long[br];
        for (int i = 0; i < br; i++) {
            a[i] = sc.nextLong();
        }
        return a;
    }
    
    public static int[][] unosPoznanstava(int br){
        Scanner sc = new Scanner(System.in);
        int[][] m = new int[br][2];
        int k = 0;
        for (int i = 0; i < br; i++) {
            while( k<2 ){
                m[i][k] = sc.nextInt();
                k++;
            }
            k = 0;
        }
        return m;
    }
    
    public static void main(String[] args) {      
        Scanner sc = new Scanner(System.in);
        // Unos broja takmicara
        int N = sc.nextInt();
        // Unos broja parova poznanika
        int M = sc.nextInt(); 
        // Unos druželjubivosti
        long[] niz = unosDruzeljubivosti(N);
        // Unos poznanstava
        int[][] matrica = unosPoznanstava(M);
        boolean b = true;   
        int l = 0;
        while( l < N ){
            if( niz[l] < 0 ){
                b = false;
            }
            l++;
        }
        int n = 0;
        long s = 0; 
        for (int i = 0; i < N; i++) {
            int a = i+1;
            for (int j = 0; j < M; j++) {
                for (int k = 0; k < 2; k++) {
                    if( matrica[j][k] == a ){
                        if( b == true )
                            n++;
                        else
                            n--;
                    }
                }
            }
            s = s + niz[i]*n;
            n = 0;
        }
        
        System.out.println(s);
    }
}