N, M = gets.chomp.split().map(&:to_i)
arr = gets.chomp.split().map(&:to_i)
s = []
 
M.times do
  a, b = gets.chomp.split().map(&:to_i)
  s.push([b] * a)
end
 
s =  s.flatten.sort.reverse
 
 
N.times do |n|
  min = arr.min
  if min < s[n]
  	arr[arr.index(min)] = s[n]
  end
end
 
puts arr.inject(:+)