# https://atcoder.jp/contests/abc127/tasks/abc127_d

n, m = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i).sort

ops = []

m.times do
  max_cards, cand_num = gets.split.map(&:to_i)
  ops << [max_cards, cand_num]
end

ops.sort_by! { |op| op[1] }
ops.reverse!

current_head = 0

ops.each do |op|
  times = 0
  max_cards, cand_num = op

  deletes = []
  adds = []
  # nums.each_with_index do |i, idx|
  current_head.upto(nums.size - 1) do |idx|
    break if times == max_cards
    break if nums[idx] > cand_num
    times += 1
    # if cand_num > nums[idx]
    nums[idx] = cand_num
    current_head += 1
      # nums.delete_at(idx)
    # end
  end
  deletes.each { |i| nums.delete_at(i)}
  nums.push(*adds)
end

# p nums
# puts nums.size
puts nums.inject(:+)