#abc368b. B - Decrease 2 max elements

B - Decrease 2 max elements

Score : 200200 points

问题陈述

你得到了一个由 NN 个正整数组成的序列 A=(A1,A2,,AN)A = (A_1, A_2, \dots ,A_N)。高桥会重复以下操作,直到 AA 中包含一个或更少的正元素:

  • AA 按降序排序。然后,将 A1A_1A2A_2 都减少 11

找出他执行这个操作的次数。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

You are given a sequence of NN positive integers A=(A1,A2,,AN)A = (A_1, A_2, \dots ,A_N). Takahashi repeats the following operation until AA contains one or fewer positive elements:

  • Sort AA in descending order. Then, decrease both A1A_1 and A2A_2 by 11.

Find the number of times he performs this operation.

Constraints

  • 2N1002 \leq N \leq 100
  • 1Ai1001 \leq A_i \leq 100
  • All input values are integers.

Input

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

NN

A1A_1 A2A_2 \cdots ANA_N

Output

Print the answer.

Sample Input 1

4
1 2 3 3

Sample Output 1

4

The process goes as follows:

  • After the 1st operation, AA is (2,2,2,1)(2, 2, 2, 1).
  • After the 2nd operation, AA is (1,1,2,1)(1, 1, 2, 1).
  • After the 3rd operation, AA is (1,0,1,1)(1, 0, 1, 1).
  • After the 4th operation, AA is (0,0,1,0)(0, 0, 1, 0). AA no longer contains more than one positive elements, so the process ends here.

Sample Input 2

3
1 1 100

Sample Output 2

2