시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 28 | 8 | 7 | 50.000% |
There is a complete graph with m vertices. Initially, the edges of the graph are not colored. Snuke performed the following operation for each i(1 ≤ i ≤ n): Choose ai vertices from the graph and paint all edges that connect two of the chosen points with color i. It turned out that no edges were painted more than once. Compute the minimal possible value of m.
First line of the input contains one integer n (1 ≤ n ≤ 5). Then n lines follow, i-th of these lines contains one integer ai (2 ≤ ai ≤ 109).
Print the minimal possible value of m.
2 3 3
5
5 2 3 4 5 6
12
Number the vertices of the graph: 1, 2, 3, 4, 5. For example, you can color the graph in the following way: