import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int DEBUG_LEVEL = 0;
void print()(){ writeln(""); }
void print(T, A ...)(T t, lazy A a){ write(t), print(a); }
void print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }

void main(string[] args){
	if(args.length > 1 && args[1] == "-debug"){
		if(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;
		else DEBUG_LEVEL = 1;
	}
	
	int n = read.to!int;
	int m = read.to!int;
	
	long[] as;
	foreach(i; 0 .. n) as ~= read.to!long;
	
	int[] bs;
	long[] cs;
	foreach(j; 0 .. m) bs ~= read.to!int, cs ~= read.to!long;
	
	int[long] xc;
	foreach(a; as){
		if(a !in xc) xc[a] = 0;
		xc[a] += 1;
	}
	
	foreach(i; 0 .. m){
		int b = bs[i];
		long c = cs[i];
		if(c !in xc) xc[c] = 0;
		xc[c] += b;
	}
	
	long[] ks = xc.keys;
	ks.sort!"a>b"();
	
	long ans;
	foreach(k; ks){
		if(xc[k] <= n){
			ans += k * xc[k];
			n -= xc[k];
			continue;
		}
		else{
			ans += k * n;
			n = 0;
			break;
		}
	}
	
	ans.writeln;
	
}

