n, m = gets.chomp.split(" ").map(&:to_i)
a_arr = gets.chomp.split(" ").map(&:to_i).sort
min = a_arr.min

m.times do |i|
  b, c = gets.chomp.split(" ").map(&:to_i)
  next if c <= min
  min = 1000000000
  a_arr.each_with_index do |a, j|
    if c > a then
      a_arr[j] = c
      b -= 1
    end
    min = a if a < min
    break if b == 0
  end
  a_arr.sort!
end

puts a_arr.inject(0) {|sum,x| sum + x }





