n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
a.sort!
b=[]
m.times do
  g = gets.split.map(&:to_i)
  b << g
end
b.sort_by!{|k,v| -v}
i = 0
b.each do |k,v|
  j = 0
  while a[i] < v && j < k
    a[i] = v
    i += 1
    j += 1
  end
end
p a.inject(:+)