n,m = gets.chomp.split().map(&:to_i)
a = gets.chomp.split().map(&:to_i)
a.sort!

bc = []
m.times do
  bc.push gets.chomp.split().map(&:to_i)
end

bc.sort_by!{|b,c| -c}
ans = []
a.each do |e|
  if bc.empty?
    ans.push e
  else
    b, c = bc[0]
    if c <= e
      bc = []
      ans.push e
    else
      ans.push c
      b -= 1
      if b == 0
        bc.shift
      else
        bc[0] = [b, c]
      end
    end
  end
end

puts ans.inject(:+)
