def insert(e, sorted)
  i = sorted.size.times.find { |i| e <= sorted[i] } || sorted.size
  sorted.insert(i, e)
end

n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort

k = []
m.times do
  b, c = gets.split.map(&:to_i)
  b.times do |i|
    break if a[i] >= c
    a[i] = c
  end

  sorted = a[b..-1]
  a[0...b].each { |e| sorted = insert(e, sorted) }                                                                                                                                                                                                                         
  a = sorted
end

puts a.reduce(0) { |a, e| a + e }