n, m = gets.split(" ").map(&:to_i)
cards = gets.split(" ").map(&:to_i)
changers = []
m.times do
  changers.push(gets.split(" ").map(&:to_i))
end

cards.sort!

changers.sort! {|a,b| a[1] <=> b[1]}.reverse!

biggest_changers = []

changers.each do |changer|
  changer[0].times do
    biggest_changers.push(changer[1])
    if biggest_changers.length > n
      break
    end
  end
  if biggest_changers.length > n
    break
  end
end

(n - biggest_changers.length).times do
  biggest_changers.push 0
end

cards.each_with_index do |card, index|
  if cards[index] < biggest_changers[index]
    cards[index] = biggest_changers[index]
  else
    break
  end
end

puts cards.inject(:+)