import std.stdio, std.conv, std.string, std.math, std.regex, std.range, std.ascii, std.algorithm;

void main(){
	auto ip = readln.split.to!(long[]), N=ip[0], M=ip[1];
	auto A = readln.split.to!(long[]).sort();
	foreach(i; 0..M){
		auto BC = readln.split.to!(long[]), B=BC[0], C=BC[1];
		foreach(j; 0..B){
			if(A[j] <= C){
				A[j] = C;
			}
		}
		A.sort();
	}
	writeln(A.sum);
}