import java.util.Scanner;

public class Prijatelji {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int K, L, SP=0,SN=0,neg=0;
        int[] A = new int[N];
        int[] Tp = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt();
            Tp[i] = 0;
        }
        for (int i = 0; i < M; i++) {
                K = scan.nextInt();
                L = scan.nextInt();
                Tp[K-1]=Tp[K-1]+1;
                Tp[L-1]=Tp[L-1]+1;
        }
        for(int i=0;i<N;i++){
            if(A[i]<0)neg++;
        }
        if(neg%2==0) {
            for (int i = 0; i < N; i++) {
                SP += A[i] * Tp[i];
            }
            System.out.println(SP);
        }
        else {
            for (int i = 0; i < N; i++) {
                SN += (A[i] * Tp[i]*-1);
            }
            System.out.println(SN);
        }


    }
}