N, M = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i)
processes = A.map! { |a| [1, a] }
M.times { processes << gets.chomp.split.map(&:to_i) }
processes = processes.sort_by { |a| a[1] }

num = 0
ans = 0
while num < N
  process = processes.pop
  process[0] = N - num if process[0] > N - num
  ans += process[0] * process[1]
  num += process[0]
end

puts ans
