CF1866A.Ambitious Kid

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Ambitious Kid

Chaneka, Pak Chanek's child, is an ambitious kid, so Pak Chanek gives her the following problem to test her ambition.

Given an array of integers [A1,A2,A3,,AN][A_1, A_2, A_3, \ldots, A_N]. In one operation, Chaneka can choose one element, then increase or decrease the element's value by 11. Chaneka can do that operation multiple times, even for different elements.

What is the minimum number of operations that must be done to make it such that $A_1 \times A_2 \times A_3 \times \ldots \times A_N = 0$?

Input

The first line contains a single integer NN (1N1051 \leq N \leq 10^5).

The second line contains NN integers A1,A2,A3,,ANA_1, A_2, A_3, \ldots, A_N (105Ai105-10^5 \leq A_i \leq 10^5).

Output

An integer representing the minimum number of operations that must be done to make it such that $A_1 \times A_2 \times A_3 \times \ldots \times A_N = 0$.

Note

In the first example, initially, A1×A2×A3=2×(6)×5=60A_1\times A_2\times A_3=2\times(-6)\times5=-60. Chaneka can do the following sequence of operations:

  1. Decrease the value of A1A_1 by 11. Then, A1×A2×A3=1×(6)×5=30A_1\times A_2\times A_3=1\times(-6)\times5=-30
  2. Decrease the value of A1A_1 by 11. Then, A1×A2×A3=0×(6)×5=0A_1\times A_2\times A_3=0\times(-6)\times5=0

In the third example, Chaneka does not have to do any operations, because from the start, it already holds that $A_1\times A_2\times A_3\times A_4\times A_5=0\times(-1)\times0\times1\times0=0$

Samples

3
2 -6 5
2
1
-3
3
5
0 -1 0 1 0
0

在线编程 IDE

建议全屏模式获得最佳体验