process.stdin.resume();
process.stdin.setEncoding('utf8'); 
var lines = [];
var reader = require('readline').createInterface({
	input: process.stdin,
	output: process.stdout
});
 
reader.on('line', (line) => {
	lines.push(line);
});

reader.on('close', () => {
	"use strict"
	const N = +lines[0].split(" ")[0];
	const M = +lines[0].split(" ")[1];
	const A = lines[1].split(" ").map(Number);
	const B = Array.from(Array(M), (e,i) => 
		+lines[i+2].split(" ")[0]);
	const C = Array.from(Array(M), (e,i) => 
		+lines[i+2].split(" ")[1]);
		
	const opes = Array.from(Array(M), (e,i) => 
		({B:B[i], C:C[i]})).concat(A.map(a => 
		({B:1, C:a}))).sort((x,y) => y.C-x.C);
	
	let ans = 0;
	let b = 0;
	let c = 0;
	for(let i=0; i<N; i++){
		if(!b){
			const bc = opes.shift();
			b = bc.B;
			c = bc.C;
		}
		b--;
		ans += c;
	}
	
	console.log(ans);
});