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

  total = total + d[i] - a[i]
end

puts total
