N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
O = Array.new(M) { gets.split.map(&:to_i) }
A.sort!
O.sort_by! {|o| o[1] }.reverse!
i, j = 0, 0
while i < N
  break if O[j][1] < A[i]
  A[i] = O[j][1]
  i += 1
  O[j][0] -= 1
  j += 1 if O[j][0] == 0
end
p A.inject(:+)