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

bc = []

a = a.sort

0.step(m - 1) do |i|
  k = gets.chomp.split(' ').map(&:to_i)
  index = a.bsearch_index {|aa| aa > k[1]} || n-1
  next if index == 0
  a = a.insert(index, *Array.new(k[0]){ k[1] })[k[0], n-1+k[0]]
end

p a.sort.reverse.take(n).inject(:+)