n, m = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)
change_array = []
m.times { change_array.push(gets.chomp.split.map(&:to_i)) }

a.sort!
change_array.sort_by! { |item| item[1] }

change_number = change_array.pop
result =0
a.each do |a_item|
  if change_number.nil? || change_number[1] < a_item
    result += a_item
  else
    result += change_number[1]
    change_number[0] -= 1
    change_number = change_array.pop if change_number[0] < 1
  end
end
puts result