#P11797. 【MX-X9-T1】『GROI-R3』Another Me

【MX-X9-T1】『GROI-R3』Another Me

Background

A huge repulsive force strikes. Your whole body seems to split into transparent fragments.

In the mirror there is a blurry figure. Is it “you”? Or is it just an illusion? There is no way to know. You want to move forward, but the other side retreats with extreme coordination. When you step back, the other side catches up again.

There is no energy left to support you to keep thinking. But toward that faint light source in the center of the prism, no matter what, you want to get a little closer. Also, there is the other “you” on the opposite side......

Problem Description

Given an integer sequence a1,,ana_1,\ldots,a_n of length nn. You may perform any number of operations (including zero). In each operation, you must choose one of the following two types:

  • Global increment by 11: for every 1in1 \leq i \leq n, increment aia_i by 11.
  • Global decrement by 11: for every 1in1 \leq i \leq n, decrement aia_i by 11.

You want to minimize maxi=1nai\max\limits_{i=1}^n \lvert a_i \rvert after the operations, i.e., minimize the maximum value among all ai\lvert a_i\rvert, where ai\lvert a_i\rvert denotes the absolute value of aia_i. You only need to compute this minimized value.

Input Format

The first line contains a positive integer nn.

The second line contains nn integers a1,,ana_1,\ldots,a_n, describing the given sequence.

Output Format

Output one line containing one integer, the minimum possible value of maxi=1nai\max\limits_{i=1}^n \lvert a_i \rvert.

5
-5 -2 0 2 3

4

6
1 -1 4 5 -1 4

3

18
9 9 8 2 4 4 3 5 3 0 9 0 2 2 8 1 1 5

5

Hint

Sample Explanation #1.

You only need to apply one global increment by 11 to obtain a=[4,1,1,3,4]a = [-4, -1, 1, 3, 4]. Then $\lvert a_1 \rvert, \lvert a_2 \rvert, \lvert a_3 \rvert, \lvert a_4 \rvert, \lvert a_5 \rvert$ are 4,1,1,3,44, 1, 1, 3, 4 respectively, and the maximum is 44. It can be proven that 44 is the minimum value you can achieve.

Constraints.

Test Point ID nn \le ai\lvert a_i \rvert \le Special Property
121\sim 2 22 100100
343\sim 4 33 500500
565\sim 6 1010 10410^4
787\sim 8 3030 10610^6
9109\sim 10 5050 10810^8
111211\sim 12 100100 55
131613\sim 16 10910^9 A
171817\sim 18 B
192019\sim 20
  • Special Property A: nn is guaranteed to be even, and for every integer kk satisfying 1kn21 \leq k \leq \frac n2, a2k1=a2ka_{2k-1} = -a_{2k}.
  • Special Property B: ai0a_i \geq 0 is guaranteed.

For 100%100\% of the testdata, it is guaranteed that 1n1001 \leq n \leq 100 and 109ai109-10^9 \leq a_i \leq 10^9.

Translated by ChatGPT 5