"use strict";
function main(input) {
    const args = input.split("\n");
    const one = args[0].split(" ");
    const two = args[1].split(" ");

    const N = parseInt(one[0]);
    const M = parseInt(one[1]);

    let SelectedCards = [];
    // { HM: 0, V: 1 };
    let tempCard

    for(let i = 0; i < M; i++) {
        tempCard = args[2+i].split(" ");
        SelectedCards.push({ V: parseInt(tempCard[1]), HM: parseInt(tempCard[0])});
    }

    SelectedCards.sort((a, b) => { return a.V < b.V ? 1 : -1});

    let Cards = [];

    for (let i = 0; i < N; i++) {
        Cards.push(parseInt(two[i]));
    }

    Cards.sort((a, b) => { return a < b ? 1 : -1 });

    let sc_point = 0;
    let c_point = 0;
    let ans = 0;
    for(let i = 0; i < N; i++) {
        if(SelectedCards[sc_point].V < Cards[c_point]) {
            ans += Cards[c_point];
            c_point++;
        } else {
            ans += SelectedCards[sc_point].V;
            if(SelectedCards[sc_point].HM !== 1) {
                SelectedCards[sc_point].HM--;
            } else {
                sc_point++;
            }
        }
        if (SelectedCards[sc_point] === undefined ) {
            SelectedCards[sc_point] = { V: 0, HM: 0 };
        } else if (Cards[c_point] === undefined) {
            CardsCards[c_point] = 0;
        }
    }
    console.log(ans)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
