nm = gets().split(" ");
n = nm[0].to_i;
m = nm[1].to_i;
a = gets().split(" ");
for i in 0..n-1
	a[i] = a[i].to_i;
end
a = a.sort;
for j in 1..m
	bc = gets().split(" ");
	b = bc[0].to_i;
	c = bc[1].to_i 
	for k in 0..b-1
		if c > a[k]
			a[k] = c;
		end
	end
	a = a.sort;
end
puts(a.inject(:+))