N, M = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort.push(1<<20)
#p a
k = 0
$<.read.split.map(&:to_i).each_slice(2).to_a.sort_by{|x|-x[1]}.each do |b, c|
#	k = a.bsearch_index{ |x| c <= x }
	break if k == N
	b.times do
		if a[k] < c
			a[k] = c
		else
			break
		end
		k+=1
		break if k==N
	end	
#break if k.nil?
#	(k-1).downto(0 > k-b ? 0 : k-b).each do |i|
#		a[i] = c
#		p [i,a]
#	end

#	p [a,b,c]
#	p [k,c,a[k]]

end
a.pop
p a.inject(:+)
