'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).sort((a, b) => b - a);
  let AnsArr = [];
  let total = 0;
  let totalMax = Math.pow(10, 9) * CardN;
 
  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);
    AnsArr = CardArr.slice(0, CardN);
     total = AnsArr.reduce((ttl, data) => { return ttl + data });
    if (total == totalMax) {
      break;
    }
  }
  console.log(total);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
