Packing Balls 2

Given counts of balls in K colors, pack them into boxes of capacity K where each box is all one color or all distinct colors, using as few boxes as possible.

Medium7GreedyMathNo attempts yetTime limit2sMemory limit512 MB

Problem

The balls come in KK colors. A color is an integer from 1 to KK, and there are XiX_i balls of color ii.

You want to pack all of the balls into boxes. One box holds at most KK balls.

The balls inside one box must all have different colors, or must all have the same color.

Write a program that finds the minimum number of boxes you need.

Input

The first line contains the number of colors KK. (1K100,0001 \le K \le 100{,}000)

The second line contains X1,X2,,XKX_1, X_2, \dots, X_K, the ball counts of color 1 through color KK, separated by spaces. (1Xi1,000,000,0001 \le X_i \le 1{,}000{,}000{,}000)

Output

Print the minimum number of boxes on the first line.