"use strict";
function Main(input) {
  const args = input.split('\n');
  const NM = args.shift().split(' ').map(m => parseInt(m));
  const N = NM.shift();
  const M = NM.shift();
  const A = args.shift().split(' ')
  .map(m => parseInt(m))
  .sort((a, b) => a - b);

  const BCs = args
  .map(m => m.split(' ').map(m2 => parseInt(m2)))
  .sort((a, b) => b[1] - a[1]);
  let idx = 0;
  for (let BC of BCs) {
    let B = BC.shift();
    const C = BC.shift();
    while(B > 0 && idx <= A.length) {
      if (A[idx] < C) {
        A[idx] = C;
        B--;
      }
      idx++;
    }
  }
  console.log(A.reduce((p, c) => p += c));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));