import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto A = readln.split.map!(to!long).array;
    auto BC = M.iota.map!(_ => readln.split.map!(to!long).array).array;
    BC.sort!"a[1] > b[1]";
    auto pq = new BinaryHeap!(Array!long, "a > b");
    foreach (a; A) pq.insert(a);

    long ans = 0;
    foreach (bc; BC) {
        int cnt = 0;
        while (!pq.empty && pq.front < bc[1] && cnt < bc[0]) {
            ans += bc[1];
            cnt += 1;
            pq.removeFront;
        }
    }

    while (!pq.empty) {
        ans += pq.front;
        pq.removeFront;
    }

    ans.writeln;
}
