import java.util.Scanner;
public class Prijatelji {
    
    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 = new long[N];
        int d = 0;
        while ( d < N ){
            niz[d] = sc.nextLong();
            d++;
        }
        // Unos poznanstava
        int[][] matrica = new int[M][2];
        int c = 0;
        for (int i = 0; i < matrica.length; i++) {
            while( c < 2 ){
                matrica[i][c] = sc.nextInt();
                c++;
            }
            c = 0;
        }
        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;
        }
        // Ispisivanje
        System.out.println(s);
    }
}