function Main(input) {
    input = input.trim().split("\n");
    tmp = input[0].split(" ");
    var N = parseInt(tmp[0],10);
    var M = parseInt(tmp[1],10);
    var A = [];
    for(var i = 0; i < N; i++){
        A[i] = parseInt(input[1].split(" ")[i],10);
    }
    A.sort(function(a,b){
        if( a < b ) return -1;
        if( a > b ) return 1;
        return 0;
    });

    var tmpC = [];
    for(var j = 2; j <= M+1; j++){
        var B = parseInt(input[j].split(" ")[0],10);
        var C = parseInt(input[j].split(" ")[1],10);
        
        for(k = 0; k < B; k++){
            tmpC.push(C);
        }
    }
    tmpC.sort(function(a,b){
        if( a < b ) return 1;
        if( a > b ) return -1;
        return 0;
    });

    for(var i = 0; i < Math.min(A.length,tmpC.length); i++){
        if(A[i] < tmpC[i]){
            A[i] = tmpC[i];
        }
        else{
            break;
        }
    }
    var output = 0;
    for(var i = 0; i < N; i++){
        output += A[i];
    }
    console.log(output);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));