#B3959. Xiao Yang's Problem-Solving Plan
Xiao Yang's Problem-Solving Plan
Xiao Yang's Problem-Solving Plan
Xiao Yang has devised a plan to improve his skills. On the \(k\)-th day, he must solve exactly \(k\) problems, otherwise he will slack off.
He has discovered a bank of problem sets. There are \(n\) problem sets in total, and each set contains a certain number of problems \(a_i\). However, he is very picky: he will use each problem set at most once, and on any given day he can only pick problems from one set. He does not have to solve all problems in the chosen set.
The task is to determine the maximum number of days he can continue solving problems without breaking his plan.
inputFormat
The first line of input contains a single integer \(n\) representing the number of problem sets. The second line contains \(n\) space-separated integers \(a_1, a_2, \dots, a_n\), where \(a_i\) denotes the number of problems in the \(i\)-th problem set.
outputFormat
Output a single integer representing the maximum number of days Xiao Yang can follow his problem-solving plan without slacking off.
sample
3
3 1 2
3