n, m = gets.to_s.split.map{|t|t.to_i}
a    = gets.to_s.split.map{|t|t.to_i}.sort

bcs = Array.new(m){ gets.to_s.split.map{|t|t.to_i} }.sort_by{|bc| -bc[1] }

i = 0
bcs.each do |bc|
  
  b = bc[0]
  c = bc[1]
  
  while b > 0 && i < n
    
    if a[i] < c
      # p [b,c,a[i]]
      a[i] = c
      b -= 1
    end
    
    i += 1
  end
end

# p a
puts a.sum

# c > a[i]: 変更; a[i] = c; b -= 1; i+=1;
# c < a[i]: 変更しない。i+=1を繰り返して、c>a[i]