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

M.times do |i|
  b, c = gets.split(' ').map(&:to_i)
  a = (a + Array.new(b, c)).sort.reverse[0, N]
end

puts a.sort.reverse[0, N].inject(:+)