#P11242. 碧树
碧树
Background
English statement. You must submit your code at the Chinese version of the statement.
Little T does not know what communication is.
Is it to understand a string of strange symbols, and then put it into someone else’s brain?
Is it to obtain some abstract knowledge, and then use it to break one’s own habits?
In order to communicate, Little T finally decided to connect to a voltage of .
Problem Description
t1k1x1ww。
Little T stares at this string of symbols that he cannot understand, and decides to first communicate an OI problem with you.
Little T has a rooted tree. It has a total of leaf nodes, and he also tells you that the depths of these leaf nodes are . Please help him compute the minimum number of nodes this tree can contain. Little T guarantees that there exists at least one such tree.
If you are not familiar with some definitions in the statement, we are happy to remind you:
- A simple path in a graph is a path that does not repeat vertices and does not repeat edges.
- A tree is a connected graph in which there is exactly one simple path between any two vertices. In a tree, we choose one node as the root.
- A leaf node in a tree is a node that is not the root and has degree .
- The depth of a node in a tree is the number of nodes on the simple path from that node to the root.
Input Format
The first line contains an integer .
The next line contains integers, describing .
Output Format
Output a single integer on one line, representing the answer.
4
2 3 4 5
8
7
6 6 7 8 4 2 4
14
Hint
Sample Explanation
- For the first group of testdata, the following is one possible tree:

Its size is . The depths of leaves are , respectively. It is easy to prove that no tree of size satisfies the requirements.
Constraints and Notes
This problem uses bundled tests and subtask dependencies.
- Subtask 0 (0 pts): samples.
- Subtask 1 (30 pts): .
- Subtask 2 (30 pts): .
- Subtask 3 (40 pts): no special restrictions. Depends on subtasks .
For all data, it is guaranteed that , , and there exists at least one such tree.
Translated by ChatGPT 5