You have N cards. On the i-th card, an integer A_i is written.

For each j = 1, 2, ..., M in this order, you will perform the following operation once:

Operation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.

Find the maximum possible sum of the integers written on the N cards after the M operations.

Constraints

* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* 1 \leq A_i, C_i \leq 10^9
* 1 \leq B_i \leq N

Input

Input is given from Standard Input in the following format:


N M
A_1 A_2 ... A_N
B_1 C_1
B_2 C_2
\vdots
B_M C_M


Output

Print the maximum possible sum of the integers written on the N cards after the M operations.

Examples

Input

3 2
5 1 4
2 3
1 5


Output

14


Input

10 3
1 8 5 7 100 4 52 33 13 5
3 10
4 30
1 4


Output

338


Input

3 2
100 100 100
3 99
3 99


Output

300


Input

11 3
1 1 1 1 1 1 1 1 1 1 1
3 1000000000
4 1000000000
3 1000000000


Output

10000000001
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void execute(CustomReader in) throws IOException {
        int[] nm = in.readLineAsIntArray();
        final int N = nm[0];
        final int M = nm[1];
        int[] A = in.readLineAsIntArray();
        Operation[] ops = new Operation[M];
        Arrays.sort(A);

        for (int i = 0; i < M; i++) {
            int[] bc = in.readLineAsIntArray();
            ops[i] = new Operation(bc[0], bc[1]);
        }
        Arrays.sort(ops, (x, y) -> (y.C == x.C) ? y.B - x.B : y.C - x.C);

        int[] rep = new int[N];
        int k = 0;
        for (int i = 0; i < ops.length; i++) {
            if (k >= N) {
                k = N;
                break;
            }
            Arrays.fill(rep, k, Math.min(N, k + ops[i].B), ops[i].C);
            k += ops[i].B;
        }
        long sum = 0L;

        for (int i = 0; i < N; i++) {
            if (i < k) {
                sum += Math.max(rep[i], A[i]);
            }else{
                sum += A[i];
            }
        }
        System.out.println(sum);
    }

    static class Operation {
        int B;
        int C;

        public Operation(int b, int c) {
            B = b;
            C = c;
        }

    }

    static class CustomReader extends BufferedReader {

        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in));
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }

    }
}