n, m = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i).sort!
change_array = []
for i in 0..(m-1) do
  b, c = gets.chomp.split.map(&:to_i)
  change_array += Array.new(b, c)
end

change_array.sort!
result = 0
a.each do |a_item|
  if change_array.length > 0
    change_item = change_array.pop
    result += [change_item, a_item].max
  else
    result += a_item
  end

end

puts result