n, m = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)
a.sort!
total = a.sum
h = Hash.new(0)
a.each do |_a|
  h[_a] += 1
end
x = Hash.new(0)
m.times do
  b, c = gets.chomp.split.map(&:to_i)
  x[c] += b
end
b = []
x = x.sort {|k1,k2| k1[1] <=> k2[1]}
x.each do |k, v|
  c = [n-b.size, v].min
  c.times{b << k}
  break if b.size >= n
end
b.sort!.reverse!
b.each_with_index do |c, i|
  break if a[i] >= c

  total = total + c - a[i]
end

puts total
