N,M=gets.chomp.split.map(&:to_i)
A=gets.chomp.split.map(&:to_i)
bc=M.times.map { gets.split.map(&:to_i) }
bc.sort_by!{|i,j| j }.reverse!
A.sort!

af = []
a  = A

if M > 0
  ix = A.bsearch_index{|x| x >= bc[0][1] }
  if ix != nil
    af = A[ix..-1]
    a = A[0...ix]
  end
end

M.times do |i|
  break if a.empty? || a[0]>bc[i][1]
  b = [a.bsearch_index{|x| x >= bc[i][1]}||a.size, bc[i][0]].min
  if b > 0
    a.shift(b)
    af.push(bc[i][1]*b)
  end
end
puts (a.inject(:+)||0) + (af.inject(:+)||0)