N, M = gets.split.map(&:to_i)
cards = gets.split.map(&:to_i).sort
actions = Array.new(M) { gets.split.map(&:to_i) }.sort_by{|a| -a[1] }

result = 0

cards.each do |tmp|
  j = actions.first&.dig(1)
  if j && j > tmp
    result += j
    if actions.first[0] - 1 == 0
      actions.shift
    else
      actions[0] = [actions.first[0] - 1, actions.first[1]]
    end
  else
    result += tmp
  end
end

puts result
