n, m = gets.chomp.split(' ').map(&:to_i)
cards = gets.chomp.split(' ').map(&:to_i)

#controlls = []
change_times = 0
all_nums = cards
m.times do |i|
  b, c = gets.chomp.split(' ').map(&:to_i)
  #controlls << [b, c]
  b.times {|j| all_nums << c }
  change_times = change_times + b
end

sorted_num = all_nums.sort.reverse

sum = 0
n.times do |i|
  sum = sum + sorted_num[i]
end

print sum