n, m = gets.chomp.split(' ').map(&:to_i)
a = gets.chomp.split(' ').map(&:to_i).sort
bc = []
m.times do
  bc <<  gets.chomp.split(' ').map(&:to_i)
end
bc.sort_by!{|(b,c)| -c}
i = 0
bc.each do |(b, c)|
  j = 0
  b.times do
    if a[i+j] < c
      a[i+j] = c
    else
      break
    end
    j += 1
    break if a[i+j].nil?
  end
  i += j
  break if a[i+j].nil?
end
puts a.inject(0){|sum, n| sum + n}