n,m = gets.split.map(&:to_i)
cards = gets.split.map(&:to_i)
raptor = []
saurus = []

m.times do
b,c = gets.split.map(&:to_i)
raptor << b
saurus << c
end

for k in 0..m-1
  cards.sort!
  ind = cards.find_index{|v| v >= saurus[k]}
  if ind <= raptor[k]
    for i in 0..(ind-1)
      cards[i] = saurus[k]
    end
  else
    for i in 0..(raptor[k]-1)
      cards[i] = saurus[k]
    end
  end
end
sum = 0
for h in 0..(cards.size-1)
  sum += cards[h]
end
puts sum