#abc313a. A - To Be Saikyo

A - To Be Saikyo

Score : 100100 points

问题描述

设有 NN 名编号为 11NN 的人。每个人都有一个整数得分,称为编程能力;编号为 ii 的人的编程能力为 PiP_i 分。为了让编号为 11 的人成为最强者,他需要多少更多的分数?换句话说,最小的非负整数 xx 是多少,使得对于所有 i1i \neq 1,有 P1+x>PiP_1 + x > P_i

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There are NN people numbered 11 through NN. Each person has a integer score called programming ability; person ii's programming ability is PiP_i points. How many more points does person 11 need, so that person 11 becomes the strongest? In other words, what is the minimum non-negative integer xx such that P1+x>PiP_1 + x > P_i for all i1i \neq 1?

Constraints

  • 1N1001\leq N \leq 100
  • 1Pi1001\leq P_i \leq 100
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN

P1P_1 P2P_2 \dots PNP_N

Output

Print the answer as an integer.

Sample Input 1

4
5 15 2 10

Sample Output 1

11

Person 11 becomes the strongest when their programming skill is 1616 points or more, so the answer is 165=1116-5=11.

Sample Input 2

4
15 5 2 10

Sample Output 2

0

Person 11 is already the strongest, so no more programming skill is needed.

Sample Input 3

3
100 100 100

Sample Output 3

1

update @ 2024/3/10 08:54:43