import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int[] a, int[][] bc) {
    a.sort();
    bc.sort!"a[1] > b[1]";

    long ans = 0;
    int p = 0;
    foreach (x; bc) {
        int b = x[0], c = x[1];
        if (p >= a.length) break;

        for (int i = 0; i < b; i++) {
            if (p >= a.length) break;
            if (a[p] >= c) break; // 書き換えると値が小さくなる

            // a[p + i] を c に置き換える
            ans += c;
            p++;
        }
    }

    for (int i = p; i < a.length; i++) {
        ans += a[i];
    }
    return ans;
}

void main() {
    int n, m; scan(n, m);
    auto a = readints;
    int[][] bc;
    for (int i = 0; i < m; i++) bc ~= readints;

    writeln(calc(a, bc));
}
