namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] x = Console.ReadLine().Split();
            int N = Int32.Parse(x[0]);
            int M = Int32.Parse(x[1]);
            int i, srec = 0, flag = 0;
            int[] A = new int[N];
            int[] X = new int[M];
            int[] Y = new int[M];
            for (i = 0; i < N; i++)
            {
                A[i] = int.Parse(Console.ReadLine());
                if (A[i] < 0)
                    flag = 1;
            }
            for(i=0;i<M;i++)
            {
                x = Console.ReadLine().Split();
                X[i] = Int32.Parse(x[0]);
                Y[i] = Int32.Parse(x[0]);
            }
            for(i=0;i<N;i++)
            {
                if (i >= M)
                {
                    if (flag == 0)
                        srec += A[i] * (1 - 0);
                    else
                        srec += A[i] * (0 - 1);
                }
                else
                    if (flag == 0)
                    srec += A[i] * (X[i] - 0);
                else
                    srec += A[i] * (0 - Y[i]);
            }
            Console.WriteLine(srec);

        }
    }
}