303444: CF667B. Coat of Anticubism
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Coat of Anticubism
题意翻译
Cicasso 有 $n$ 根棍子,但这 $n$ 根棍子无法围成一个面积非零的凸多边形。 你需要增加一根棍子,使得这 $n+1$ 根棍子可以围成一个非零面积的凸多边形。 输出增加的这根棍子的最短长度。 题目保证原先给出的 $n$ 根棍子无法构成一个面积非零的凸多边形。题目描述
![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF667B/da431a35861ffb0dfb05294a401b5e75bc0d5240.png)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 ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF667B/88c61e080ae2c77e20323807b54f172a39161c4f.png). 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!输入输出格式
输入格式
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.
输出格式
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.
输入输出样例
输入样例 #1
3
1 2 1
输出样例 #1
1
输入样例 #2
5
20 4 3 2 1
输出样例 #2
11