n, m = gets.rstrip.split.map(&:to_i)
an   = gets.rstrip.split.map(&:to_i)
bcs  = m.times.map{ gets.rstrip.split.map(&:to_i) }

an.sort!

cs = []
bcs.each{ |bc| bc[0].times{ cs << bc[1] } }
cs.sort!{ |a,b| b<=>a }
#bcs.sort!{ |a,b| b[1]<=>a[1] }

sum = 0
0.upto(cs.size - 1) do | i |
  if an[i] < cs[i]
    an[i] = cs[i]
  end
  sum += an[i]
end

cs.size.upto(n-1) do | i |
  sum += an[i]
end

p sum