Codeforces Round 349 (Div. 2)
B
Coat of Anticubism
Codeforces
1100
原题
← AC →
翻译中…

image

翻译中…

As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.

翻译中…

A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to transmit two-dimensional objects through three-dimensional objects by using his magnificent sculptures. And his new project is connected with this. Cicasso wants to make a coat for the haters of anticubism. To do this, he wants to create a sculpture depicting a well-known geometric primitive — convex polygon.

翻译中…

Cicasso prepared for this a few blanks, which are rods with integer lengths, and now he wants to bring them together. The $*i*$-th rod is a segment of length $*l*_{*i*}$.

翻译中…

The sculptor plans to make a convex polygon with a nonzero area, using all rods he has as its sides. Each rod should be used as a side to its full length. It is forbidden to cut, break or bend rods. However, two sides may form a straight angle image.

翻译中…

Cicasso knows that it is impossible to make a convex polygon with a nonzero area out of the rods with the lengths which he had chosen. Cicasso does not want to leave the unused rods, so the sculptor decides to make another rod-blank with an integer length so that his problem is solvable. Of course, he wants to make it as short as possible, because the materials are expensive, and it is improper deed to spend money for nothing.

翻译中…

Help sculptor!

翻译中…

Input

翻译中…

The first line contains an integer $*n*$ ($3 ≤ *n* ≤ 10^{5}$) — a number of rod-blanks.

翻译中…

The second line contains $*n*$ integers $*l*_{*i*}$ ($1 ≤ *l*_{*i*} ≤ 10^{9}$) — lengths of rods, which Cicasso already has. It is guaranteed that it is impossible to make a polygon with $*n*$ vertices and nonzero area using the rods Cicasso already has.

翻译中…

Output

翻译中…

Print the only integer $*z*$ — the minimum length of the rod, so that after adding it it can be possible to construct convex polygon with $(*n* + 1)$ vertices and nonzero area from all of the rods.

翻译中…

Note

翻译中…

In the first example triangle with sides ${1 + 1 = 2, 2, 1}$ can be formed from a set of lengths ${1, 1, 1, 2}$.

翻译中…

In the second example you can make a triangle with lengths ${20, 11, 4 + 3 + 2 + 1 = 10}$.

翻译中…

样例

Input #1
3
1 2 1
Output #1
1
InputCopy OutputCopy
Input #2
5
20 4 3 2 1
Output #2
11
InputCopy OutputCopy
题目信息
题号
667B
时间限制
1 s
内存限制
256 MB
标签
构造
计算几何

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。