n, m = gets.chomp.split(' ').map(&:to_i)
a = gets.chomp.split(' ').map(&:to_i).sort
bc = []
m.times do
  b, c = gets.chomp.split(' ').map(&:to_i)
  b.times do
    bc << c
  end
end
bc = bc.sort.reverse
sum = 0
a.each do |n|
  t = bc.shift
  if !t.nil? && t > n
    sum += t
  else
    sum += n
  end
end
puts sum
