n, m = gets.split(" ").map(&:to_i)
cards = gets.split(" ").map(&:to_i)

m.times do
  cards.sort!
  b, c = gets.split(" ").map(&:to_i)
  b.times do |i|
    if cards[i] < c
      cards[i] = c
    else
      break
    end
  end
end

puts cards.sum
