'use strict'

const INF = 900719925474099;


function Main(input){
    let temp = input.trim().split('\n');
    let temp2 = temp[0].split(' ').map((v)=>parseInt(v));
    let n = temp2.shift();
    let m = temp2.shift();
    let a = temp[1].split(' ').map((v)=>parseInt(v));

    let b = new Array(m);

    for(let i=2;i<=m+1;i++){
        temp2 = temp[i].split(' ').map((v)=>parseInt(v));
        b[i-2] = {b:temp2[0],c:temp2[1]};
    }
    a.sort((a,b)=>a-b);
    b.sort((d,e)=>e.c-d.c);

    let t = 0;
    let count = 0;
    //console.log('----------------',b);
    for(let i=0;i<n;i++){
        //console.log(a,'t:',t,'count:',count,b[t]);
        if(b[t].c <= a[i]){
            //console.log('break');
            break;
        }
        count++;
        a[i] = b[t].c;
        if(b[t].b <= count){
            t++;
            if(t>=m) break;
            count = 0;
        }
    }

    let sum=0;
    for(let i=0;i<n;i++){
        sum += a[i];
    }

    console.log(sum);
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
