CF1206B.Make Product Equal One

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

Make Product Equal One

You are given nn numbers a1,a2,,ana_1, a_2, \dots, a_n. With a cost of one coin you can perform the following operation:

Choose one of these numbers and add or subtract 11 from it.

In particular, we can apply this operation to the same number several times.

We want to make the product of all these numbers equal to 11, in other words, we want a1a2a_1 \cdot a_2 \dots an=1\cdot a_n = 1.

For example, for n=3n = 3 and numbers [1,3,0][1, -3, 0] we can make product equal to 11 in 33 coins: add 11 to second element, add 11 to second element again, subtract 11 from third element, so that array becomes [1,1,1][1, -1, -1]. And 1(1)(1)=11\cdot (-1) \cdot (-1) = 1.

What is the minimum cost we will have to pay to do that?

Input

The first line contains a single integer nn (1n1051 \le n \le 10^5) — the number of numbers.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (109ai109-10^9 \le a_i \le 10^9) — the numbers.

Output

Output a single number — the minimal number of coins you need to pay to make the product equal to 11.

Note

In the first example, you can change 11 to 1-1 or 1-1 to 11 in 22 coins.

In the second example, you have to apply at least 44 operations for the product not to be 00.

In the third example, you can change 5-5 to 1-1 in 44 coins, 3-3 to 1-1 in 22 coins, 55 to 11 in 44 coins, 33 to 11 in 22 coins, 00 to 11 in 11 coin.

Samples

2
-1 1
2
4
0 0 0 0
4
5
-5 -3 5 3 0
13

在线编程 IDE

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