n,m = gets.split.map(&:to_i)
cards = gets.split.map(&:to_i).sort
m.times do
  b,c = gets.split.map(&:to_i)
  b.times do |index|
    if cards[index] < c
      cards[index] = c 
    else
      break
    end
  end
  cards.sort!
end
puts cards.inject(:+)