# 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!

ops.each do |op|
  nums.sort!
  times = 0
  max_cards, cand_num = op
  nums.each_with_index do |i, idx|
    break if times == max_cards
    times += 1
    if cand_num > i
      nums[idx] = cand_num
    end
  end
end

# p nums
puts nums.inject(:+)