N,M=gets.split.map(&:to_i)
as=gets.split.map(&:to_i).sort
bcs=$<.read.split.map(&:to_i).each_slice(2).sort_by {|b,c|c}

b,c = bcs.pop
ret = 0
as.each do |a|
  if b.nil?
    ret += a
  elsif a < c
    ret += c
    b -= 1
    b,c = bcs.pop if b == 0
  else
    ret += a
  end
end

p ret
