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

changes = []
m.times do
  changes << gets.split(" ").map(&:to_i)
end

changes = changes.sort_by {|_, x| x}.reverse

end_flag = false
i = 0
changes.each do |data|
  data[0].times do
    if cards[i] < data[1]
      cards[i] = data[1]
    else
      end_flag = true
      break
    end
    i += 1
    if i >= n
      end_flag = true
      break
    end
  end
  break if end_flag
end


sum = 0
cards.each{|x| sum += x}
puts sum
