N,M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort
BC = readlines.map {|a| a.split.map(&:to_i) }.sort_by(&:last).reverse
ans = 0
BC.each do |b,c|
  n = A[0, b].index {|a| a >= c } || [b, A.size].min
  break if n == 0
  A.shift(n)
  ans += c * n
end
puts ans + (A.inject(:+) || 0)