N, M = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort

min = a.first
bc = []

M.times do
  b, c = gets.split.map(&:to_i)
  bc << [b, c]
end
bc = bc.sort_by{|a| a[1]}.reverse
M.times do |i|
  b, c = bc[i]
  if c > min
    b.times do
      x = a.shift
      if x < c
        a << c
      else
        a = [x] + a
        min = x
        break
      end
    end
    min = a.first
  end
end
puts a.inject(&:+)