N, M = gets.chomp.split.map(&:to_i)
cards = gets.chomp.split.map(&:to_i)

M.times do
  b, c = gets.chomp.split.map(&:to_i)
  cards += Array.new(b) {c}
end

cards = cards.sort.reverse

sum = 0
N.times do |i|
  sum += cards[i]
end

puts sum
