Time limit
2s
Memory limit
128 MB
Sungji's birthday is three days away. At midnight between Sunday and Monday, a birthday party will be held in room 902. Sungji always attends, and some students may be invited.
There are N students who want to attend. Student i is satisfied only if, when that student is invited, at least k_i other students also attend, not counting that student or Sungji.
Sungji wants to invite as few students as possible while satisfying every invited student's requirement. Given N and all k_i values, find the minimum number of students to invite.
The first line contains the number of students N. (1 <= N <= 10,000)
Each of the next N lines contains one student's value k_i.
Print the minimum number of students that can be invited while satisfying all invited students.
When two students both have k = 1, inviting only one student does not work because that student has no other student beside them. Inviting both students works because each student has exactly one other student present.