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

T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }

void main() {
    immutable ip = readln.split.to!(ulong[]);
    immutable n = ip[0], m = ip[1];

    auto as = readln.split.to!(ulong[]).sort;
    auto ops = new Tuple!(ulong, "b", ulong, "c")[m];

    for(ulong i = 0; i < m; i++) {
        immutable ip1 = readln.split.to!(ulong[]);
        immutable b = ip1[0], c = ip1[1];
        ops[i] = tuple!("b", "c")(b, c);
    }

    ops.sort!((x, y) {
        if (x.c == y.c) return (x.b > y.b);
        return (x.c > y.c);
    });

    ulong idx = 0;
    ulong sum = 0;

    for(ulong i = 0; i < ops.length && idx < n; i++) {
        if (ops[i].c <= as[idx]) {
            sum += as[idx++];
        } else {
            for(ulong j = 0; j < ops[i].b && ops[i].c > as[idx]; j++) {
                sum += ops[i].c;
                idx++;
            }
        }
    }

    while (idx < n) {
        sum += as[idx++];
    }

    writeln(sum);

}
