N,M=gets.split.map &:to_i
r=[[0,0]]
gets.split.map(&:to_i).sort.each do |a|
  if a == r[-1][0]
    r[-1][1] += 1
  else
    r << [a, 1]
  end
end
M.times do
  b, c = gets.split.map &:to_i
  r << [c, b]
end

sum = [0, N]
r.sort.reverse.each do |(c, b)|
  cnt = [sum[1], b].min
  sum[0] += c * cnt
  sum[1] -= cnt
end
p sum[0]