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

void main() {
    alias T = Tuple!(long, "c", long, "b");

    long n, m;
    readf("%d %d\n", &n, &m);
    auto as = readln.strip.split(" ").map!(to!long).array;
    auto xs = new T[](m);

    foreach (i; 0..m) {
        long b, c;
        readf("%d %d\n", &b, &c);
        xs[i] = T(c, b);
    }
    as = sort(as).array;
    xs = sort!"a > b"(xs).array;

    long p = 0;
proc: foreach (x; xs) {
        foreach (_; 0..x.b) {
            if (x.c <= as[p]) {
                break proc;
            }
            as[p] = x.c;
            p++;
        }
    }

    long ans = as.sum();
    writeln(ans);
}
