#GD0000138. Maria mời bạn ra sân (Maria Breaks the Self-isolation)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Maria mời bạn ra sân (Maria Breaks the Self-isolation)
Maria Breaks the Self-isolation
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Initially only Maria is in the courtyard. There are friends; friend agrees to appear if at least other people are present at the same time, including Maria and friends appearing simultaneously. Maria may invite any number of uninvited friends together, provided every invited friend sees enough other people. Maximize the total attendance including Maria.
Input
The first line contains . The next line contains values .
Output
Print the maximum number of attendees, including Maria.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
6
1 5 4 5 1 9
Output
6
Explanation
Invite the two friends requiring one other person; attendance becomes three. Then invite simultaneously the friends requiring others: each sees five other attendees. The friend requiring nine cannot join. Answer .