def max(a,b); a > b ? a : b; end
  
N = gets.to_i
A = gets.split.map(&:to_i)
C = A.each_with_object(Array.new(N + 1, 0)){|i,c| c[i] += 1 }
D = C.each_with_object(Array.new(N + 1, 0)){|j,d| d[j] += 1 }
E = Array.new(N + 1, 0)
(1 .. N).each{|k| E[k] = E[k - 1] + k * D[k] }
F = Array.new(N + 1, 0)
(1 .. N).each{|k| F[k] = F[k - 1] + D[k] }

def max_size(m)
  (E[m] + m * (F[N] - F[m])) / m
end

dp = Array.new(N + 1, 0)
(1 .. N).each{|m| dp[m] = max_size(m) }
G = Array.new(N + 1, 0)

dp.each_with_index do |k,m|
  G[k] = m
end

(1 .. N).reverse_each.inject(0) do |s,i|
  G[i] = max(s, G[i])
end

puts G[1 .. N]
