'use strict'
const Main = (input) => {
  let tmp = input.split('\n');
  let CardN = tmp[0].split(' ').map(Number)[0];
  let OpeN = tmp[0].split(' ').map(Number)[1];
  let CardArr = tmp[1].split(' ').map(Number);

  for (let i = 1; i <= OpeN; i++) {
    let C = tmp[i + 1].split(' ').map(Number)[0];
    let N = tmp[i + 1].split(' ').map(Number)[1];
    for (let j = 1; j <= C; j++) {
      CardArr.push(N);
    }
  }

  CardArr.sort((a, b) => b - a);
  let AnsArr = CardArr.slice(0, CardN);
  let total = AnsArr.reduce((total, data) => { return total + data });
  console.log(total);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
