N, M = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
bcs = []
M.times do |i|
  bcs << gets.split.map(&:to_i)
end
bcs2 = bcs.map { |b, c| [c] * b }.flatten

puts (as + bcs2).sort.reverse[0..N-1].inject(:+)
