n,m=gets.split.map(&:to_i)
as=gets.split.map(&:to_i)
changes=[]
m.times do
  bn,cn=gets.split.map(&:to_i)
  changes.push([cn]*bn)
  changes.flatten!.sort!
  if changes.size>n
    changes=changes.slice(-n..-1)
  end
end
all=(as+changes).sort
puts all[-n..-1].inject(:+)
