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

list = []
m.times do
  list << gets.split.map(&:to_i)
end
list.sort_by!{|t| t[1]}.reverse!
idx = 0
list.each do |b,c|
  break if a[idx] >= c
  b.times do
    if a[idx] < c
      a[idx] = c
      idx += 1
    end
    break if idx > n-1
  end
  break if idx > n-1
end
p a.reduce(:+)
