n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

a.sort!
rep = []
m.times do
  b, c = gets.split.map(&:to_i)
  i = rep.bsearch_index{|v| v > c}
  if i.nil?
    rep += ([c] * b)
  else
    rep.insert(i, *([c]*b))
  end
  f = rep.size - n
  f = 0 if f < 0
  rep = rep[f..-1]
end
  

rep.reverse!
(0...rep.size).each do |i|
  if a[0] < rep[i]
    a.shift
    pos = a.bsearch_index{|v| v > rep[i]}
    if pos.nil?
      a << rep[i]
    else
	  a.insert(pos, rep[i])
    end
  end
end

puts a.reduce(:+)
