You are given an integer sequence of length N. The i-th term in the sequence is a_i.
In one operation, you can select a term and either increment or decrement it by one.
At least how many operations are necessary to satisfy the following conditions?
 - For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero.
 - For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.

-----Constraints-----
 - 2 ≤ n ≤ 10^5
 - |a_i| ≤ 10^9
 - Each a_i is an integer.

-----Input-----
Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n

-----Output-----
Print the minimum necessary count of operations.

-----Sample Input-----
4
1 -3 1 0

-----Sample Output-----
4

For example, the given sequence can be transformed into 1, -2, 2, -2 by four operations. The sums of the first one, two, three and four terms are 1, -1, 1 and -1, respectively, which satisfy the conditions.

Difficulty: MEDIUM_HARD

Starter code:

Solutions:
N = int(input())
A = [int(_) for _ in input().split()]

def calc(A, y):
	result = abs(A[0] - y)
	t = y
	if t == 0:
		return 10 ** 30
	for a in A[1:N]:
		tt = t + a
		if t * tt >= 0:
			m = -t // abs(t)
			result += abs(m - tt)
			tt = m
		t = tt
	return result
result = min(calc(A, A[0]), calc(A, -1), calc(A, +1))
print(result)


n = int(input())
a = list(map(int, input().split()))
ans1 = 0
s = 0
for (i, v) in enumerate(a):
	if i % 2 and s + v >= 0:
		ans1 += abs(-1 - s - v)
		s = -1
	elif i % 2 == 0 and s + v <= 0:
		ans1 += abs(1 - s - v)
		s = 1
	else:
		s += v
s = 0
ans2 = 0
for (i, v) in enumerate(a):
	if i % 2 and s + v <= 0:
		ans2 += abs(1 - s - v)
		s = 1
	elif i % 2 == 0 and s + v >= 0:
		ans2 += abs(-1 - s - v)
		s = -1
	else:
		s += v
print(min(ans1, ans2))


n = int(input())
a = list(map(int, input().split()))

def cost(a, neg=False):
	sign = -1 if neg else 1
	if sign * a[0] > 0:
		ret = 0
		cum = a[0]
	else:
		ret = abs(a[0] - sign)
		cum = sign
	for i in range(1, n):
		sign *= -1
		cum += a[i]
		if cum * sign > 0:
			continue
		else:
			ret += abs(cum - sign)
			cum = sign
	return ret
print(min(cost(a, False), cost(a, True)))


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	lst = tuple(map(int, input().split()))
	(cur, cnt_1) = (0, 0)
	for (i, j) in enumerate(lst):
		new = cur + j
		if i % 2 == 0 and new <= 0:
			cnt_1 += abs(new) + 1
			cur = 1
		elif i % 2 == 1 and new >= 0:
			cnt_1 += abs(new) + 1
			cur = -1
		else:
			cur += j
	(cur, cnt_2) = (0, 0)
	for (i, j) in enumerate(lst):
		new = cur + j
		if i % 2 == 0 and new >= 0:
			cnt_2 += abs(new) + 1
			cur = -1
		elif i % 2 == 1 and new <= 0:
			cnt_2 += abs(new) + 1
			cur = 1
		else:
			cur += j
	print(min(cnt_1, cnt_2))

def __starting_point():
	main()
__starting_point()


N = int(input())
A = list(map(int, input().split()))
pos = 0
now = 0
for (i, a) in enumerate(A):
	now += a
	if i % 2 == 0:
		if now <= 0:
			pos += -now + 1
			now = 1
	elif now >= 0:
		pos += now + 1
		now = -1
neg = 0
now = 0
for (i, a) in enumerate(A):
	now += a
	if i % 2 == 0:
		if now >= 0:
			neg += now + 1
			now = -1
	elif now <= 0:
		neg += -now + 1
		now = 1
print(min(pos, neg))


N = int(input())
A = list(map(int, input().split()))

def calc(a, t):
	ans = 0
	p_flag = t < 0
	t += a
	if p_flag:
		if t < 0:
			ans = 1 - t
			t = 1
	elif t >= 0:
		ans = 1 + t
		t = -1
	if t == 0:
		ans += 1
		if p_flag:
			t = 1
		else:
			t = -1
	return (ans, t)
ans_p = 0
t_p = 0
ans_m = 0
t_m = 0
if A[0] > 0:
	ans_p = 0
	t_p = A[0]
	ans_m = A[0] + 1
	t_m = -1
elif A[0] < 0:
	ans_p = -A[0] + 1
	t_p = 1
	ans_m = 0
	t_m = A[0]
else:
	ans_p = 1
	t_p = 1
	ans_m = 1
	t_m = -1
for i in range(1, N):
	(a, t_p) = calc(A[i], t_p)
	ans_p += a
	(a, t_m) = calc(A[i], t_m)
	ans_m += a
print(min(ans_p, ans_m))


from itertools import accumulate
n = int(input())
a = list(map(int, input().split()))
a = list(accumulate(a))
ans1 = 0
tmp1 = 0
for i in range(n):
	b = a[i] + tmp1
	if i % 2 == 0 and b <= 0:
		tmp1 += 1 - b
		ans1 += 1 - b
	elif i % 2 == 1 and b >= 0:
		tmp1 += -1 - b
		ans1 += 1 + b
ans2 = 0
tmp2 = 0
for i in range(n):
	b = a[i] + tmp2
	if i % 2 == 1 and b <= 0:
		tmp2 += 1 - b
		ans2 += 1 - b
	elif i % 2 == 0 and b >= 0:
		tmp2 += -1 - b
		ans2 += 1 + b
ans = min(ans1, ans2)
print(ans)


import sys
input = sys.stdin.readline

def main():
	N = int(input())
	A = list(map(int, input().split()))
	tmp_o = [0 for i in range(N + 1)]
	tmp_e = [0 for i in range(N + 1)]
	count_o = 0
	count_e = 0
	for i in range(N):
		tmp_o[i + 1] = tmp_o[i] + A[i]
		if i % 2 == 1 and tmp_o[i + 1] <= 0:
			count_o += 1 - tmp_o[i + 1]
			tmp_o[i + 1] = 1
		elif i % 2 == 0 and tmp_o[i + 1] >= 0:
			count_o += tmp_o[i + 1] + 1
			tmp_o[i + 1] = -1
		else:
			continue
	for i in range(N):
		tmp_e[i + 1] = tmp_e[i] + A[i]
		if i % 2 == 0 and tmp_e[i + 1] <= 0:
			count_e += 1 - tmp_e[i + 1]
			tmp_e[i + 1] = 1
		elif i % 2 == 1 and tmp_e[i + 1] >= 0:
			count_e += tmp_e[i + 1] + 1
			tmp_e[i + 1] = -1
		else:
			continue
	print(min(count_o, count_e))

def __starting_point():
	main()
__starting_point()


n = int(input())
a = list(map(int, input().split()))
pm_sum = 0
pm_count = 0
mp_sum = 0
mp_count = 0
for i in range(n):
	pm_sum += a[i]
	mp_sum += a[i]
	if i % 2 == 0:
		pm_d = max(0, 1 - pm_sum)
		mp_d = max(0, mp_sum - -1)
		pm_sum += pm_d
		mp_sum -= mp_d
	else:
		pm_d = max(0, pm_sum - -1)
		mp_d = max(0, 1 - mp_sum)
		pm_sum -= pm_d
		mp_sum += mp_d
	pm_count += pm_d
	mp_count += mp_d
print(min(pm_count, mp_count))


import sys
MOD = 10 ** 9 + 7
INF = float('inf')
N = int(input())
A = list(map(int, input().split()))
res1 = 0
res2 = 0
s = 0
for i in range(N):
	s = s + A[i]
	if i % 2 == 1 and s <= 0:
		shift = -s + 1
		s += shift
		res1 += shift
	if i % 2 == 0 and s >= 0:
		shift = s + 1
		s -= shift
		res1 += shift
s = 0
for i in range(N):
	s = s + A[i]
	if i % 2 == 0 and s <= 0:
		shift = -s + 1
		s += shift
		res2 += shift
	if i % 2 == 1 and s >= 0:
		shift = s + 1
		s -= shift
		res2 += shift
print('{}'.format(min(res1, res2)))


A = int(input())
l = list(map(int, input().split()))
sum_n = 0
ans = 0
caseA = 0
for i in range(A):
	sum_n += l[i]
	if i % 2 == 0:
		if 0 < sum_n:
			continue
		else:
			ans += abs(1 - sum_n)
			sum_n = 1
	elif sum_n < 0:
		continue
	else:
		ans += abs(-1 - sum_n)
		sum_n = -1
caseA = ans
ans = 0
sum_n = 0
for i in range(A):
	sum_n += l[i]
	if i % 2 == 1:
		if 0 < sum_n:
			continue
		else:
			ans += abs(1 - sum_n)
			sum_n = 1
	elif sum_n < 0:
		continue
	else:
		ans += abs(-1 - sum_n)
		sum_n = -1
print(min(ans, caseA))


N = int(input())
A = list(map(int, input().split()))
s = 0
t = 0
a = 0
b = 0
for i in range(N):
	s += A[i]
	if i % 2 == 0:
		if s >= 0:
			a += s + 1
			s = -1
	if i % 2 != 0:
		if s <= 0:
			a += -s + 1
			s = 1
for j in range(N):
	t += A[j]
	if j % 2 != 0:
		if t >= 0:
			b += t + 1
			t = -1
	if j % 2 == 0:
		if t <= 0:
			b += -t + 1
			t = 1
print(min(a, b))


def solve(ini_val):
	(acc, cnt) = (0, 0)
	for ai in a:
		acc += ai
		if acc * ini_val < 1:
			cnt += abs(ini_val - acc)
			acc += ini_val - acc
		ini_val *= -1
	return cnt
n = int(input())
a = list(map(int, input().split()))
print(min(solve(1), solve(-1)))


n = int(input())
a = list(map(int, input().split()))
flag = 1
temp_1 = 0
temp = 0
for i in range(n):
	temp += a[i]
	if flag * temp <= 0:
		temp_1 += 1 - flag * temp
		temp = flag
	flag *= -1
flag = -1
temp_2 = 0
temp = 0
for i in range(n):
	temp += a[i]
	if flag * temp <= 0:
		temp_2 += 1 - flag * temp
		temp = flag
	flag *= -1
print(min(temp_1, temp_2))


n = int(input())
a = list(map(int, input().split()))
(x, y, z) = (0, 0, 0)
for i in range(n):
	x += a[i]
	if i % 2 == 0:
		if x > 0:
			pass
		else:
			y += 1 - x
			x = 1
	elif x < 0:
		pass
	else:
		y += x + 1
		x = -1
x = 0
for i in range(n):
	x += a[i]
	if i % 2 == 1:
		if x > 0:
			pass
		else:
			z += 1 - x
			x = 1
	elif x < 0:
		pass
	else:
		z += x + 1
		x = -1
print(min(y, z))


n = int(input())
a = list(map(int, input().split()))
ans = [0, 0]
s = max(a[0], 1)
ans[0] = abs(s - a[0])
for i in range(n - 1):
	if s * (s + a[i + 1]) >= 0:
		if s > 0:
			ans[0] += s + a[i + 1] + 1
			s = -1
		else:
			ans[0] += 1 - (s + a[i + 1])
			s = 1
	else:
		s += a[i + 1]
s = min(-1, a[0])
ans[1] = abs(s - a[0])
for i in range(n - 1):
	if s * (s + a[i + 1]) >= 0:
		if s > 0:
			ans[1] += s + a[i + 1] + 1
			s = -1
		else:
			ans[1] += 1 - (s + a[i + 1])
			s = 1
	else:
		s += a[i + 1]
print(min(ans))


n = int(input())
a = list(map(int, input().split()))
b = a[:]
(cnt1, cnt2) = (0, 0)
s = 0
for i in range(n):
	if i % 2 == 0 and s + a[i] <= 0 or (i % 2 == 1 and s + a[i] >= 0):
		cnt1 += abs(s + a[i]) + 1
		if i % 2:
			s = -1
		else:
			s = 1
	else:
		s += a[i]
s = 0
for i in range(n):
	if i % 2 == 1 and s + a[i] <= 0 or (i % 2 == 0 and s + a[i] >= 0):
		cnt2 += abs(s + a[i]) + 1
		if i % 2:
			s = 1
		else:
			s = -1
	else:
		s += a[i]
print(min(cnt1, cnt2))


n = int(input())
lst = list(map(int, input().rstrip().split()))
(cur, cnt_1) = (0, 0)
for (i, j) in enumerate(lst):
	new = cur + j
	if i % 2 == 0 and new <= 0:
		cnt_1 += abs(new) + 1
		cur = 1
	elif i % 2 == 1 and new >= 0:
		cnt_1 += abs(new) + 1
		cur = -1
	else:
		cur = new
(cur, cnt_2) = (0, 0)
for (i, j) in enumerate(lst):
	new = cur + j
	if i % 2 == 0 and new >= 0:
		cnt_2 += abs(new) + 1
		cur = -1
	elif i % 2 == 1 and new <= 0:
		cnt_2 += abs(new) + 1
		cur = 1
	else:
		cur = new
print(min(cnt_1, cnt_2))


N = int(input())
A = list(map(int, input().split()))

def sequence(plus_start):
	cost = 0
	cum = 0
	for i in range(N):
		tmp = cum + A[i]
		target = tmp
		if plus_start:
			if i % 2 == 0:
				if tmp <= 0:
					target = 1
			elif tmp >= 0:
				target = -1
		elif i % 2 == 0:
			if tmp >= 0:
				target = -1
		elif tmp <= 0:
			target = 1
		diff = target - tmp
		cum += A[i] + diff
		cost += abs(diff)
	return cost
print(min(sequence(True), sequence(False)))


import sys, math, copy
HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = 'abcdefghijklmnopqrstuvwxyz'

def next(su, ai, sign):
	assert sign in [-1, 1]
	if (su + ai) * sign > 0:
		return ai
	else:
		nextsu = sign
		nextai = nextsu - su
		return nextai

def main():
	n = int(input())
	an = list(map(int, input().split()))
	ress = HUGEL
	for beg in [-1, 1]:
		res = 0
		su = 0
		sign = beg
		for i in range(n):
			ai = next(su, an[i], sign)
			su = su + ai
			res += abs(ai - an[i])
			sign *= -1
		ress = min(ress, res)
	print(ress)
main()


N = int(input())
A = list(map(int, input().split()))
if A[0] != 0:
	A_sum = A[0]
	ans1 = 0
	for i in range(1, N):
		if A_sum < 0:
			A_sum += A[i]
			if A_sum <= 0:
				ans1 += 1 - A_sum
				A_sum = 1
		elif A_sum > 0:
			A_sum += A[i]
			if A_sum >= 0:
				ans1 += A_sum - -1
				A_sum = -1
else:
	ans1 = max(A) * N
ans2 = abs(1 - A[0])
A_sum = 1
for i in range(1, N):
	if A_sum < 0:
		A_sum += A[i]
		if A_sum <= 0:
			ans2 += 1 - A_sum
			A_sum = 1
	elif A_sum > 0:
		A_sum += A[i]
		if A_sum >= 0:
			ans2 += A_sum - -1
			A_sum = -1
ans3 = abs(A[0] - -1)
A_sum = -1
for i in range(1, N):
	if A_sum < 0:
		A_sum += A[i]
		if A_sum <= 0:
			ans3 += 1 - A_sum
			A_sum = 1
	elif A_sum > 0:
		A_sum += A[i]
		if A_sum >= 0:
			ans3 += A_sum - -1
			A_sum = -1
print(min(ans1, ans2, ans3))


n = int(input())
A = [int(x) for x in input().split()]

def f(isPlus):
	sum = 0
	ret = 0
	for a in A:
		sum += a
		if isPlus:
			if sum <= 0:
				ret += abs(sum) + 1
				sum = 1
		elif sum >= 0:
			ret += abs(sum) + 1
			sum = -1
		isPlus = not isPlus
	return ret
a1 = f(True)
a2 = f(False)
print(min(a1, a2))


import sys
import math
import itertools
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
input = sys.stdin.readline

def RD():
	return input().rstrip()

def F():
	return float(input().rstrip())

def I():
	return int(input().rstrip())

def MI():
	return map(int, input().split())

def MF():
	return map(float, input().split())

def LI():
	return list(map(int, input().split()))

def TI():
	return tuple(map(int, input().split()))

def LF():
	return list(map(float, input().split()))

def Init(H, W, num):
	return [[num for i in range(W)] for j in range(H)]

def main():
	N = input().rstrip()
	A = LI()
	if A[0] > 0:
		A1 = 0
		B1 = A[0]
		A2 = A[0] + 1
		B2 = -1
	elif A[0] == 0:
		A1 = 1
		B1 = 1
		A2 = 1
		B2 = -1
	else:
		A1 = -A[0] + 1
		B1 = 1
		A2 = 0
		B2 = A[0]
	for num in A[1:]:
		if B1 > 0:
			B1 += num
			if B1 > 0:
				A1 += B1 + 1
				B1 = -1
			elif B1 == 0:
				A1 += 1
				B1 = -1
		else:
			B1 += num
			if B1 < 0:
				A1 += -B1 + 1
				B1 = 1
			elif B1 == 0:
				B1 = 1
				A1 += 1
	for num in A[1:]:
		if B2 > 0:
			B2 += num
			if B2 > 0:
				A2 += B2 + 1
				B2 = -1
			elif B2 == 0:
				A2 += 1
				B2 = -1
		else:
			B2 += num
			if B2 < 0:
				A2 += -B2 + 1
				B2 = 1
			elif B2 == 0:
				B2 = 1
				A2 += 1
	print(min(A1, A2))

def __starting_point():
	main()
__starting_point()


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [input() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [int(input()) for i in range(n)]

class Math:

	@staticmethod
	def gcd(a, b):
		if b == 0:
			return a
		return Math.gcd(b, a % b)

	@staticmethod
	def lcm(a, b):
		return a * b // Math.gcd(a, b)

	@staticmethod
	def roundUp(a, b):
		return -(-a // b)

	@staticmethod
	def toUpperMultiple(a, x):
		return Math.roundUp(a, x) * x

	@staticmethod
	def toLowerMultiple(a, x):
		return a // x * x

	@staticmethod
	def nearPow2(n):
		if n <= 0:
			return 0
		if n & n - 1 == 0:
			return n
		ret = 1
		while n > 0:
			ret <<= 1
			n >>= 1
		return ret

	@staticmethod
	def sign(n):
		if n == 0:
			return 0
		if n < 0:
			return -1
		return 1

	@staticmethod
	def isPrime(n):
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		d = int(n ** 0.5) + 1
		for i in range(3, d + 1, 2):
			if n % i == 0:
				return False
		return True

class PriorityQueue:

	def __init__(self, l=[]):
		self.__q = l
		heapq.heapify(self.__q)
		return

	def push(self, n):
		heapq.heappush(self.__q, n)
		return

	def pop(self):
		return heapq.heappop(self.__q)
MOD = int(1000000000.0) + 7
INF = int(1000000000000000.0)

def main():
	N = Scanner.int()
	A = Scanner.map_int()
	(s1, s2) = (0, 0)
	(c1, c2) = (0, 0)
	for i in range(N):
		if i % 2 == 0:
			if s1 + A[i] > 0:
				s1 += A[i]
			else:
				c1 += abs(s1 + A[i]) + 1
				s1 = 1
			if s2 + A[i] < 0:
				s2 += A[i]
			else:
				c2 += abs(s2 + A[i]) + 1
				s2 = -1
		else:
			if s1 + A[i] < 0:
				s1 += A[i]
			else:
				c1 += abs(s1 + A[i]) + 1
				s1 = -1
			if s2 + A[i] > 0:
				s2 += A[i]
			else:
				c2 += abs(s2 + A[i]) + 1
				s2 = 1
	print(min(c1, c2))
	return

def __starting_point():
	main()
__starting_point()


n = int(input())
a = list(map(int, input().split()))
cost = 0
sum = 0
for i in range(n):
	sum += a[i]
	if i % 2 == 0:
		if sum >= 1:
			pass
		else:
			cost += 1 - sum
			sum = 1
	elif sum <= -1:
		pass
	else:
		cost += sum + 1
		sum = -1
kost = 0
kom = 0
for i in range(n):
	kom += a[i]
	if i % 2 != 0:
		if kom >= 1:
			pass
		else:
			kost += 1 - kom
			kom = 1
	elif kom <= -1:
		pass
	else:
		kost += kom + 1
		kom = -1
print(min(cost, kost))


N = int(input())
A = list(map(int, input().split()))
ans = 0

def func(A, flag):
	l = [0] * N
	ans = 0
	acc = 0
	for i in range(N):
		l[i] = A[i]
	for i in range(0, N):
		acc = acc + l[i]
		if i % 2 == flag:
			if acc >= 0:
				l[i] = l[i] - (1 + acc)
				ans += 1 + acc
				acc = -1
		elif acc <= 0:
			l[i] = l[i] + (1 - acc)
			ans += 1 - acc
			acc = 1
	return ans
print(min(func(A, 0), func(A, 1)))


n = int(input())
a = list(map(int, input().split()))
now = a[0]
if now == 0:
	ans = 1
	now = 1
else:
	ans = 0
for i in a[1:]:
	t = now + i
	if now * t >= 0:
		if now >= 0:
			ans += t + 1
			now = -1
		else:
			ans += 1 - t
			now = 1
	else:
		now = t
if a[0] >= 0:
	now = -1
	ans2 = a[0] - now
else:
	now = 1
	ans2 = now - a[0]
for i in a[1:]:
	t = now + i
	if now * t >= 0:
		if now >= 0:
			ans2 += t + 1
			now = -1
		else:
			ans2 += 1 - t
			now = 1
	else:
		now = t
ans = min(ans, ans2)
print(ans)


n = int(input())
a = list(map(int, input().split()))
a1 = 0
t = 0
for i in range(n):
	t += a[i]
	if i % 2 == 0:
		if t <= 0:
			a1 += 1 - t
			t = 1
	elif t >= 0:
		a1 += 1 + t
		t = -1
a2 = 0
t = 0
for i in range(n):
	t += a[i]
	if i % 2 == 1:
		if t <= 0:
			a2 += 1 - t
			t = 1
	elif t >= 0:
		a2 += 1 + t
		t = -1
print(min(a1, a2))


n = int(input())
a = list(map(int, input().split()))
ans1 = abs(a[0] - 1)
ans2 = abs(a[0] + 1)
ans3 = 0

def f(x, y):
	for i in range(1, n):
		if y > 0:
			y += a[i]
			if y < 0:
				continue
			else:
				x += abs(y + 1)
				y = -1
		else:
			y += a[i]
			if y > 0:
				continue
			else:
				x += abs(y - 1)
				y = 1
	return x
if a[0] == 0:
	ans3 = float('inf')
else:
	ans3 = f(ans3, a[0])
print(min(ans3, f(ans1, 1), f(ans2, -1)))


n = int(input())
a = list(map(int, input().split()))
cnt = [0, 0]
for (i, x) in zip([0, 1], [1, -1]):
	now = 0
	for aj in a:
		now += aj
		if now == 0:
			cnt[i] += 1
			now = x
		elif now * x < 0:
			cnt[i] += abs(now - x)
			now = x
		x *= -1
print(min(cnt))


N = int(input())
A = list(map(int, input().split()))
s = ans1 = 0
for (i, a) in enumerate(A):
	s += a
	if i % 2:
		if s <= 1:
			ans1 += 1 - s
			s = 1
	elif s >= -1:
		ans1 += s + 1
		s = -1
s = ans2 = 0
for (i, a) in enumerate(A):
	s += a
	if i % 2 == 0:
		if s <= 1:
			ans2 += 1 - s
			s = 1
	elif s >= -1:
		ans2 += s + 1
		s = -1
print(min(ans1, ans2))


def main():
	import sys
	input = sys.stdin.readline
	N = int(input())
	A = list(map(int, input().split()))
	tmp = 0
	tmpans1 = 0
	for i in range(N):
		tmp += A[i]
		if i % 2 == 0 and tmp <= 0:
			tmpans1 += 1 - tmp
			tmp = 1
		elif i % 2 == 1 and tmp >= 0:
			tmpans1 += 1 + tmp
			tmp = -1
	tmp = 0
	tmpans2 = 0
	for i in range(N):
		tmp += A[i]
		if i % 2 == 0 and tmp >= 0:
			tmpans2 += 1 + tmp
			tmp = -1
		elif i % 2 == 1 and tmp <= 0:
			tmpans2 += 1 - tmp
			tmp = 1
	print(min(tmpans1, tmpans2))
main()


N = int(input())
A = list(map(int, input().split()))
calc1 = 0
calc2 = 0
L = A
if L[0] > 0:
	su = L[0]
else:
	su = 1
	calc1 += 1 + abs(L[0])
for i in range(1, N):
	su += L[i]
	if i % 2:
		if su >= 0:
			calc1 += 1 + abs(su)
			su = -1
	elif su <= 0:
		calc1 += 1 + abs(su)
		su = 1
L = A
if L[0] < 0:
	su = L[0]
else:
	su = -1
	calc2 += 1 + abs(L[0])
for i in range(1, N):
	su += L[i]
	if not i % 2:
		if su >= 0:
			calc2 += 1 + abs(su)
			su = -1
	elif su <= 0:
		calc2 += 1 + abs(su)
		su = 1
print(min(calc1, calc2))


n = int(input())
a = list(map(int, input().split()))
c1 = 0
s = 0
for i in range(n):
	s += a[i]
	if i % 2:
		if s >= 0:
			c1 += s + 1
			s = -1
	elif s <= 0:
		c1 += -s + 1
		s = 1
c2 = 0
s = 0
for i in range(n):
	s += a[i]
	if i % 2:
		if s <= 0:
			c2 += -s + 1
			s = 1
	elif s >= 0:
		c2 += s + 1
		s = -1
print(min(c1, c2))


def modify_seq(seq: list, is_positive: bool) -> int:
	(cur, cnt) = (0, 0)
	for i in seq:
		cur += i
		if is_positive and cur <= 0:
			cnt += abs(cur) + 1
			cur = 1
		elif not is_positive and cur >= 0:
			cnt += abs(cur) + 1
			cur = -1
		is_positive = not is_positive
	return cnt

def main():
	(_, *A) = list(map(int, open(0).read().split()))
	print(min(modify_seq(A, True), modify_seq(A, False)))

def __starting_point():
	main()
__starting_point()


def main():
	n = int(input())
	a = list(map(int, input().split()))
	sp = 0
	sm = 0
	cntp = 0
	cntm = 0
	for i in range(n):
		sp += a[i]
		sm += a[i]
		if abs(sp) >= 1 and sp // abs(sp) == (-1) ** i:
			sp += 0
		else:
			cntp += abs(sp) + 1
			sp = (-1) ** i
		if abs(sm) >= 1 and sm // abs(sm) == (-1) ** (i + 1):
			sm += 0
		else:
			cntm += abs(sm) + 1
			sm = (-1) ** (i + 1)
	print(min(cntp, cntm))

def __starting_point():
	main()
__starting_point()


N = int(input())
A = list(map(int, input().split(' ')))
ans1 = 0
ans2 = 0
sum1 = 0
sum2 = 0
flag = True
for i in range(len(A)):
	sum1 = sum1 + A[i]
	sum2 = sum2 + A[i]
	flag = not flag
	if flag:
		if sum1 > 0:
			pass
		else:
			ans1 += abs(1 - sum1)
			sum1 = 1
		if sum2 < 0:
			pass
		else:
			ans2 += abs(-1 - sum2)
			sum2 = -1
	else:
		if sum2 > 0:
			pass
		else:
			ans2 += abs(1 - sum2)
			sum2 = 1
		if sum1 < 0:
			pass
		else:
			ans1 += abs(-1 - sum1)
			sum1 = -1
print(min(ans1, ans2))


import sys
import copy
N = int(input())
A = list(map(int, input().split()))
a = copy.deepcopy(A)
b = copy.deepcopy(A)
s = 0
cost_p = 0
cost_m = 0
for i in range(N):
	if i % 2 == 0:
		new = max(abs(s) + 1, a[i])
		cost_p += new - a[i]
		a[i] = new
		s += a[i]
	else:
		new = min(-1 * abs(s) - 1, a[i])
		cost_p += abs(new - a[i])
		a[i] = new
		s += a[i]
s = 0
for i in range(N):
	if i % 2 == 1:
		new = max(abs(s) + 1, b[i])
		cost_m += abs(new - b[i])
		b[i] = new
		s += b[i]
	else:
		new = min(-1 * abs(s) - 1, b[i])
		cost_m += abs(new - b[i])
		b[i] = new
		s += b[i]
print(min(cost_p, cost_m))


n = input()
a = [int(j) for j in input().split()]

def chk(a, t):
	ans = 0
	x = 0
	for i in a:
		x += i
		if t == True and x < 1:
			ans += 1 - x
			x = 1
		elif t == False and x > -1:
			ans += x + 1
			x = -1
		t = not t
	return ans
print(min(chk(a, True), chk(a, False)))


n = int(input())
a = list(map(int, input().split()))
p = [1, -1]
j = [-1, 1]
c = 0
l = 0
d = 0
e = 0
for i in range(n):
	s = i % 2
	c += a[i]
	l += a[i]
	if p[s] * c <= 0:
		d += abs(c - p[s])
		c = p[s]
	if j[s] * l <= 0:
		e += abs(l - j[s])
		l = j[s]
print(min(e, d))


n = int(input().strip())
a = list(map(int, input().split()))
su = 0
ans1 = 0
ans2 = 0
for i in range(n):
	if i % 2 == 0:
		su += a[i]
		if su <= 0:
			ans1 += abs(su - 1)
			su = 1
	if i % 2 == 1:
		su += a[i]
		if su >= 0:
			ans1 += abs(su + 1)
			su = -1
su = 0
for i in range(n):
	if i % 2 == 0:
		su += a[i]
		if su >= 0:
			ans2 += abs(su + 1)
			su = -1
	if i % 2 == 1:
		su += a[i]
		if su <= 0:
			ans2 += abs(su - 1)
			su = 1
print(min(ans1, ans2))


(N,) = list(map(int, input().split()))
A = list(map(int, input().split()))
s = 0
r = 0
for (i, a) in enumerate(A):
	s += a
	if i % 2:
		if s >= 0:
			r += s + 1
			s = -1
	elif s <= 0:
		r += -s + 1
		s = 1
s = 0
r2 = 0
for (i, a) in enumerate(A):
	s += a
	if i % 2:
		if s <= 0:
			r2 += -s + 1
			s = 1
	elif s >= 0:
		r2 += s + 1
		s = -1
print(min(r, r2))


N = int(input())
L = list(map(int, input().split()))
Pnum = 0
Psum = 0
if L[0] >= 1:
	Pnum = L[0]
else:
	Psum = 1 - L[0]
	Pnum = 1
for i in range(1, N):
	if i % 2 == 1:
		if Pnum + L[i] <= -1:
			Pnum = Pnum + L[i]
		else:
			Psum += Pnum + L[i] + 1
			Pnum = -1
	elif Pnum + L[i] >= 1:
		Pnum = Pnum + L[i]
	else:
		Psum += 1 - Pnum - L[i]
		Pnum = 1
Mnum = 0
Msum = 0
if L[0] <= -1:
	Mnum = L[0]
else:
	Msum = L[0] + 1
	Mnum = -1
for i in range(1, N):
	if i % 2 == 0:
		if Mnum + L[i] <= -1:
			Mnum = Mnum + L[i]
		else:
			Msum += Mnum + L[i] + 1
			Mnum = -1
	elif Mnum + L[i] >= 1:
		Mnum = Mnum + L[i]
	else:
		Msum += 1 - Mnum - L[i]
		Mnum = 1
print(min(Psum, Msum))


n = int(input())
lis = list(map(int, input().split()))
cou = 0
co = 0
ans1 = 0
ans2 = 0
for i in range(n):
	cou += lis[i]
	co += lis[i]
	if cou <= 0 and i % 2 == 0:
		ans1 += 1 - cou
		cou = 1
	if cou >= 0 and i % 2 == 1:
		ans1 += cou + 1
		cou = -1
	if co >= 0 and i % 2 == 0:
		ans2 += co + 1
		co = -1
	if co <= 0 and i % 2 == 1:
		ans2 += 1 - co
		co = 1
print(min(ans1, ans2))


def ri():
	return int(input())

def rl():
	return list(input().split())

def rli():
	return list(map(int, input().split()))

def solve(la):
	ans = 0
	s = la[0]
	for i in range(1, len(la)):
		a = la[i]
		ns = s + a
		if s * ns < 0:
			s = ns
			continue
		ans += abs(ns) + 1
		if ns < 0:
			ns += abs(ns) + 1
		else:
			ns -= abs(ns) + 1
		s = ns
	return ans

def main():
	n = ri()
	la = rli()
	first = la[0]
	ans1 = 0
	if first <= 0:
		ans1 += abs(first) + 1
		la[0] = 1
	ans1 += solve(la)
	ans2 = 0
	la[0] = first
	if first >= 0:
		ans2 += abs(first) + 1
		la[0] = -1
	ans2 += solve(la)
	print(min(ans1, ans2))

def __starting_point():
	main()
__starting_point()


n = int(input())
a = list(map(int, input().split()))

def calc(tmp, cnt=0):
	for i in a[1:]:
		if tmp < 0:
			tmp = tmp + i
			if tmp <= 0:
				cnt += -tmp + 1
				tmp = 1
		elif tmp > 0:
			tmp = tmp + i
			if tmp >= 0:
				cnt += tmp + 1
				tmp = -1
	return cnt
if a[0]:
	hugou = 1 if a[0] > 0 else -1
	print(min(calc(a[0]), calc(-hugou, abs(a[0]) + 1)))
else:
	print(min(calc(1, 1), calc(-1, 1)))


n = int(input())
l = list(map(int, input().split()))
ans = 0

def func(l, pn):
	ans = 0
	sum_ = 0
	for i in range(n):
		sum_ += l[i]
		if sum_ >= 0 and pn[i] < 0:
			ans += sum_ + 1
			sum_ = -1
		elif sum_ <= 0 and pn[i] > 0:
			ans += -sum_ + 1
			sum_ = 1
		else:
			continue
	return ans
pn1 = [1 if i % 2 == 0 else -1 for i in range(n)]
pn2 = [-1 if i % 2 == 0 else 1 for i in range(n)]
print(min(func(l, pn1), func(l, pn2)))


import sys
read = sys.stdin.read
readline = sys.stdin.readline
(n, *a) = map(int, read().split())
for i in range(1, n):
	a[i] += a[i - 1]
aa = a[:]
sgn = 1
r1 = 0
v = 0
for i in range(n):
	a[i] += v
	if sgn:
		if a[i] <= 0:
			r1 += -a[i] + 1
			v += -a[i] + 1
	elif a[i] >= 0:
		r1 += a[i] + 1
		v -= a[i] + 1
	sgn ^= 1
a = aa
sgn = 0
r2 = 0
v = 0
for i in range(n):
	a[i] += v
	if sgn:
		if a[i] <= 0:
			r2 += -a[i] + 1
			v += -a[i] + 1
	elif a[i] >= 0:
		r2 += a[i] + 1
		v -= a[i] + 1
	sgn ^= 1
print(min(r1, r2))


def ARC072C():
	N = int(input())
	a = list(map(int, input().split()))
	cnt1 = 0
	cnt2 = 0
	sum1 = a[0]
	sum2 = a[0]
	if sum1 <= 0:
		cnt1 = 1 - a[0]
		sum1 = 1
	if sum2 >= 0:
		cnt2 = abs(-1 - a[0])
		sum2 = -1
	j = 1
	for i in range(1, N):
		sum1 += a[i]
		sum2 += a[i]
		if j % 2 == 0:
			if sum1 <= 0:
				cnt1 += 1 - sum1
				sum1 = 1
			if sum2 >= 0:
				cnt2 += abs(-1 - sum2)
				sum2 = -1
		else:
			if sum1 >= 0:
				cnt1 += abs(-1 - sum1)
				sum1 = -1
			if sum2 <= 0:
				cnt2 += 1 - sum2
				sum2 = 1
		j += 1
	print(min(cnt1, cnt2))
ARC072C()


N = int(input())
A = [int(_) for _ in input().split()]
pos_count = 0
sign = 1
cumsum = 0
for a in A:
	cumsum += a
	if cumsum * sign <= 0:
		pos_count += abs(sign - cumsum)
		cumsum = sign
	sign *= -1
neg_count = 0
sign = -1
cumsum = 0
for a in A:
	cumsum += a
	if cumsum * sign <= 0:
		neg_count += abs(sign - cumsum)
		cumsum = sign
	sign *= -1
print(min(pos_count, neg_count))


N = int(input())
A = list(map(int, input().split()))
B = A.copy()
ans = [0, 0]
flag1 = True
flag2 = False
for i in range(0, N):
	if i != 0:
		A[i] += A[i - 1]
	if flag1:
		if A[i] <= 0:
			ans[0] += abs(A[i]) + 1
			A[i] = 1
		flag1 = False
	else:
		if A[i] >= 0:
			ans[0] += abs(A[i]) + 1
			A[i] = -1
		flag1 = True
for i in range(0, N):
	if i != 0:
		B[i] += B[i - 1]
	if flag2:
		if B[i] <= 0:
			ans[1] += abs(B[i]) + 1
			B[i] = 1
		flag2 = False
	else:
		if B[i] >= 0:
			ans[1] += abs(B[i]) + 1
			B[i] = -1
		flag2 = True
print(min(ans))


n = int(input())
(*A,) = map(int, input().split())
even = 0
odd = 0
S = 0
for (i, a) in enumerate(A):
	S += a
	if i % 2 == 0 and S <= 0:
		even += -S + 1
		S = 1
	elif i % 2 == 1 and S >= 0:
		even += S + 1
		S = -1
S = 0
for (i, a) in enumerate(A):
	S += a
	if i % 2 == 0 and S >= 0:
		odd += S + 1
		S = -1
	elif i % 2 == 1 and S <= 0:
		odd += -S + 1
		S = 1
print(min(even, odd))


def inpl():
	return [int(i) for i in input().split()]

def minich(A, plus):
	ans = 0
	back = 0
	for i in A:
		if plus:
			if back + i < 0:
				back = back + i
			else:
				ans += back + i + 1
				back = -1
		elif back + i > 0:
			back = back + i
		else:
			ans += 1 - back - i
			back = 1
		plus = not plus
	return ans
N = int(input())
A = inpl()
print(min(minich(A, True), minich(A, False)))


n = int(input())
r = [int(i) for i in input().split()]
for i in range(1, n):
	r[i] += r[i - 1]
a = r.copy()
ans_a = 0
change_v = 0
for i in range(n):
	a[i] += change_v
	if i % 2 == 1:
		ans_a += max(0, 1 - a[i])
		change_v += max(0, 1 - a[i])
	else:
		ans_a += max(0, a[i] + 1)
		change_v -= max(0, a[i] + 1)
a = r.copy()
ans_b = 0
change_v = 0
for i in range(n):
	a[i] += change_v
	if i % 2 == 0:
		ans_b += max(0, 1 - a[i])
		change_v += max(0, 1 - a[i])
	else:
		ans_b += max(0, a[i] + 1)
		change_v -= max(0, a[i] + 1)
print(min(ans_a, ans_b))


def main():
	n = int(input())
	lst = list(map(int, input().rstrip().split()))
	cnt = [0] * 2
	cur = 0
	for (i, j) in enumerate(lst):
		cur += j
		if i % 2 == 0 and cur <= 0:
			cnt[0] += abs(cur) + 1
			cur = 1
		elif i % 2 == 1 and cur >= 0:
			cnt[0] += abs(cur) + 1
			cur = -1
	cur = 0
	for (i, j) in enumerate(lst):
		cur += j
		if i % 2 == 0 and cur >= 0:
			cnt[1] += abs(cur) + 1
			cur = -1
		elif i % 2 == 1 and cur <= 0:
			cnt[1] += abs(cur) + 1
			cur = 1
	print(min(cnt))

def __starting_point():
	main()
__starting_point()


n = int(input())
a = list(map(int, input().split()))
b = [0, 0]
for p in range(2):
	s = 0
	for i in range(n):
		t = s + a[i]
		if (i + p) % 2 == 0:
			if t <= 0:
				b[p] += 1 - t
				s = 1
			else:
				s = t
		elif t >= 0:
			b[p] += 1 + t
			s = -1
		else:
			s = t
print(min(b))


n = int(input())
A = list(map(int, input().split()))
N = A[:]
ncount = 0
if N[0] >= 0:
	ncount += abs(N[0]) + 1
	N[0] = -1
for i in range(1, n):
	N[i] += N[i - 1]
	if i % 2 == 1:
		if N[i] <= 0:
			ncount += abs(N[i]) + 1
			N[i] = 1
	elif N[i] >= 0:
		ncount += abs(N[i]) + 1
		N[i] = -1
P = A[:]
pcount = 0
if P[0] <= 0:
	pcount += abs(P[0]) + 1
	P[0] = 1
for i in range(1, n):
	P[i] += P[i - 1]
	if i % 2 == 0:
		if P[i] <= 0:
			pcount += abs(P[i]) + 1
			P[i] = 1
	elif P[i] >= 0:
		pcount += abs(P[i]) + 1
		P[i] = -1
print(min(ncount, pcount))


n = int(input())
a = list(map(int, input().split()))
ans1 = 0
ans2 = 0
sum1 = 0
sum2 = 0
for i in range(n):
	sum1 += a[i]
	sum2 += a[i]
	if sum1 * (-1) ** i >= 0:
		ans1 += abs(sum1) + 1
		sum1 = -(-1) ** i
	if sum2 * (-1) ** i <= 0:
		ans2 += abs(sum2) + 1
		sum2 = (-1) ** i
print(min(ans1, ans2))


n = int(input())
a = list(map(int, input().split()))
ans = 0
sum = 0
for i in range(n):
	sum += a[i]
	if sum * (-1) ** i <= 0:
		ans += abs(sum) + 1
		sum = (-1) ** i
ans2 = 0
sum = 0
for i in range(n):
	sum += a[i]
	if sum * (-1) ** i >= 0:
		ans2 += abs(sum) + 1
		sum = -(-1) ** i
print(min(ans, ans2))


n = int(input())
a = [int(_) for _ in input().split()]
ans1 = 0
ans2 = 0
tmp1 = 0
tmp2 = 0
flag = False
for i in a:
	tmp1 += i
	if flag and tmp1 <= 0:
		ans1 += 1 - tmp1
		tmp1 = 1
	elif not flag and tmp1 >= 0:
		ans1 += tmp1 + 1
		tmp1 = -1
	if flag:
		flag = False
	else:
		flag = True
flag = True
for i in a:
	tmp2 += i
	if flag and tmp2 <= 0:
		ans2 += 1 - tmp2
		tmp2 = 1
	elif not flag and tmp2 >= 0:
		ans2 += tmp2 + 1
		tmp2 = -1
	if flag:
		flag = False
	else:
		flag = True
print(min(ans1, ans2))


n = int(input())
a = list(map(int, input().split()))
ans = 0
ansans = 0
now = 0
for i in range(n):
	now += a[i]
	if i % 2 == 0:
		if now < 0:
			ans += abs(now) + 1
			now = 1
		elif now == 0:
			ans += 1
			now = 1
	elif now >= 0:
		ans += abs(now) + 1
		now = -1
	elif now == 0:
		ans += 1
		now = -1
now = 0
for i in range(n):
	now += a[i]
	if i % 2 == 0:
		if now > 0:
			ansans += abs(now) + 1
			now = -1
		elif now == 0:
			ansans += 1
			now = -1
	elif now < 0:
		ansans += abs(now) + 1
		now = 1
	elif now == 0:
		ansans += 1
		now = 1
print(min(ans, ansans))


def main():
	n = int(input())
	A = list(map(int, input().split()))
	ans = 0
	s = A[0]
	plus_flag = True
	if A[0] <= 0:
		ans += -A[0] + 1
		s = 1
	v1 = eval(s, ans, plus_flag, A)
	ans = 0
	s = A[0]
	plus_flag = False
	if A[0] >= 0:
		ans += A[0] + 1
		s = -1
	v2 = eval(s, ans, plus_flag, A)
	print(min(v1, v2))

def eval(s, ans, plus_flag, A):
	for a in A[1:]:
		if plus_flag is True:
			plus_flag = False
			if s + a == 0:
				ans += 1
				s = -1
			elif s + a > 0:
				ans += s + a + 1
				s = -1
			else:
				s = s + a
		elif plus_flag is False:
			plus_flag = True
			if s + a == 0:
				ans += 1
				s = 1
			elif s + a < 0:
				ans += -(s + a) + 1
				s = 1
			else:
				s = s + a
	return ans

def __starting_point():
	main()
__starting_point()


n = int(input())
a = list(map(int, input().split()))
ans1 = 0
s1 = 0
for i in range(n):
	s1 += a[i]
	if i % 2 == 0:
		if s1 <= 0:
			ans1 += 1 - s1
			s1 = 1
	elif s1 >= 0:
		ans1 += s1 + 1
		s1 = -1
ans2 = 0
s2 = 0
for i in range(n):
	s2 += a[i]
	if i % 2 == 1:
		if s2 <= 0:
			ans2 += 1 - s2
			s2 = 1
	elif s2 >= 0:
		ans2 += s2 + 1
		s2 = -1
print(min(ans1, ans2))


n = int(input())
a = list(map(int, input().split()))
count1 = a[0]
count2 = a[0]
answer1 = 0
answer2 = 0
if a[0] <= 0:
	answer1 += 1 - a[0]
	count1 = 1
if a[0] >= 0:
	answer2 += 1 + a[0]
	count2 = -1
for i in a[1:]:
	if count1 > 0 and count1 + i < 0 or (count1 < 0 and count1 + i > 0):
		count1 += i
		continue
	else:
		answer1 += abs(count1 + i) + 1
		if count1 > 0:
			count1 = -1
		else:
			count1 = 1
for i in a[1:]:
	if count2 > 0 and count2 + i < 0 or (count2 < 0 and count2 + i > 0):
		count2 += i
		continue
	else:
		answer2 += abs(count2 + i) + 1
		if count2 > 0:
			count2 = -1
		else:
			count2 = 1
print(min(answer1, answer2))


n = int(input())
a = list(map(int, input().split()))
ans = 0
b = 0
for i in range(0, n):
	if i % 2 == 1:
		if b + a[i] < 1:
			ans += abs(b + a[i]) + 1
			b = 1
		else:
			b += a[i]
	elif b + a[i] > -1:
		ans += abs(b + a[i]) + 1
		b = -1
	else:
		b += a[i]
ansa = 0
bb = 0
for i in range(n):
	if i % 2 == 0:
		if bb + a[i] < 1:
			ansa += abs(bb + a[i]) + 1
			bb = 1
		else:
			bb += a[i]
	elif bb + a[i] > -1:
		ansa += abs(bb + a[i]) + 1
		bb = -1
	else:
		bb += a[i]
print(min(ans, ansa))


import copy
n = int(input())
a = list(map(int, input().split()))

def f(org_a, odd):
	a = copy.copy(org_a)
	ans = 0
	if a[0] == 0:
		a[0] = 1 if odd else -1
		ans += 1
	elif a[0] > 0 and (not odd):
		ans += a[0] + 1
		a[0] = -1
	elif a[0] < 0 and odd:
		ans += -a[0] + 1
		a[0] = 1
	current_sum = a[0]
	for i in range(1, len(a)):
		move = 0
		is_positive = current_sum > 0
		current_sum += a[i]
		if is_positive and current_sum >= 0:
			move = -current_sum - 1
		elif not is_positive and current_sum <= 0:
			move = -current_sum + 1
		current_sum += move
		a[i] += move
		ans += abs(move)
	return ans
print(min(f(a, True), f(a, False)))


N = int(input())
A = list(map(int, input().split()))
temp = 0
pans = 0
isp = True
for i in range(N):
	temp += A[i]
	if isp:
		if temp <= 0:
			pans += -temp + 1
			temp = 1
		elif A[i] == 0:
			pans += 1
			temp += 1
	elif temp >= 0:
		pans += temp + 1
		temp = -1
	elif A[i] == 0:
		pans += 1
		temp -= 1
	isp = not isp
temp = 0
mans = 0
isp = False
for i in range(N):
	temp += A[i]
	if isp:
		if temp <= 0:
			mans += -temp + 1
			temp = 1
		elif A[i] == 0:
			mans += 1
			temp += 1
	elif temp >= 0:
		mans += temp + 1
		temp = -1
	elif A[i] == 0:
		mans += 1
		temp -= 1
	isp = not isp
print(min(pans, mans))


n = int(input())
A = [int(i) for i in input().split()]
if A[0] > 0:
	s = A[0]
	ans1 = 0
else:
	s = 1
	ans1 = -A[0] + 1
for i in range(1, n):
	if s * (s + A[i]) >= 0:
		ans1 += abs(s + A[i]) + 1
		if s > 0:
			s = -1
		else:
			s = 1
	else:
		s += A[i]
if A[0] < 0:
	s = A[0]
	ans2 = 0
else:
	s = -1
	ans2 = A[0] + 1
for i in range(1, n):
	if s * (s + A[i]) >= 0:
		ans2 += abs(s + A[i]) + 1
		if s > 0:
			s = -1
		else:
			s = 1
	else:
		s += A[i]
print(min(ans1, ans2))


class Bit:

	def __init__(self, n):
		self.n = n
		self.tree = [0] * (n + 1)
		self.depth = n.bit_length() - 1

	def sum(self, i):
		s = 0
		i -= 1
		while i >= 0:
			s += self.tree[i]
			i = (i & i + 1) - 1
		return s

	def built(self, array):
		for (i, a) in enumerate(array):
			self.add(i, a)

	def add(self, i, x):
		while i < self.n:
			self.tree[i] += x
			i |= i + 1

	def get(self, i, j):
		if i == 0:
			return self.sum(j)
		return self.sum(j) - self.sum(i)

	def lower_bound(self, x, equal=False):
		sum_ = 0
		pos = -1
		if not equal:
			for i in range(self.depth, -1, -1):
				k = pos + (1 << i)
				if k < self.n and sum_ + self.tree[k] < x:
					sum_ += self.tree[k]
					pos += 1 << i
		if equal:
			for i in range(self.depth, -1, -1):
				k = pos + (1 << i)
				if k < self.n and sum_ + self.tree[k] <= x:
					sum_ += self.tree[k]
					pos += 1 << i
		return (pos, sum_)

	def __getitem__(self, i):
		return self.get(i, i + 1)

	def __iter__(self):
		for i in range(self.n):
			yield self.get(i, i + 1)

	def __str__(self):
		text1 = ' '.join(['element:            '] + list(map(str, self)))
		text2 = ' '.join(['cumsum(1-indexed):  '] + list((str(self.sum(i)) for i in range(1, self.n + 1))))
		return '\n'.join((text1, text2))

def solve(sign):
	B = Bit(N)
	B.built(A)
	res = 0
	for i in range(N):
		tmp = B.sum(i + 1)
		if tmp * sign > 0:
			B.add(i, -1 * sign * (abs(tmp) + 1))
			res += abs(tmp) + 1
		elif tmp == 0:
			B.add(i, -1 * sign)
			res += 1
		sign *= -1
	return res
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
print(min(solve(-1), solve(1)))


n = int(input())
a = list(map(int, input().split()))
s = 0
anse = 0
for i in range(n):
	s += a[i]
	if i % 2 == 0 and s <= 0:
		anse += 1 - s
		s = 1
	elif i % 2 == 1 and s >= 0:
		anse += s + 1
		s = -1
s = 0
anso = 0
for i in range(n):
	s += a[i]
	if i % 2 == 0 and s >= 0:
		anso += s + 1
		s = -1
	elif i % 2 == 1 and s <= 0:
		anso += 1 - s
		s = 1
ans = min(anse, anso)
print(ans)


n = int(input())
a = list(map(int, input().split()))
s1 = max(1, a[0])
s2 = min(-1, a[0])
d = [0] * n
p = [0] * n
d[0] = [0, abs(a[0]) + 1][a[0] <= 0]
p[0] = [0, abs(a[0]) + 1][a[0] >= 0]
for i in range(n - 1):
	if s1 ** 2 + a[i + 1] * s1 < 0:
		d[i + 1] = d[i]
		s1 += a[i + 1]
	else:
		d[i + 1] = d[i] + abs(s1 + a[i + 1]) + 1
		s1 = [-1, 1][s1 < 0]
	if s2 ** 2 + a[i + 1] * s2 < 0:
		p[i + 1] = p[i]
		s2 += a[i + 1]
	else:
		p[i + 1] = p[i] + abs(s2 + a[i + 1]) + 1
		s2 = [-1, 1][s2 < 0]
print(min(d[n - 1], p[n - 1]))


N = int(input())
a = list(map(int, input().split()))
num = float('inf')
for k in [0, 1]:
	s = 0
	tmp = 0
	for i in range(N):
		s += a[i]
		if i % 2 == k:
			if s <= 0:
				tmp += abs(s) + 1
				s = 1
		elif s >= 0:
			tmp += abs(s) + 1
			s = -1
	num = min(tmp, num)
print(num)


def getInt():
	return int(input())

def getIntList():
	return [int(x) for x in input().split()]

def db(x):
	nonlocal debug
	if debug:
		print(x)

def count(N, A, initSum):
	sm = initSum
	cnt = abs(sm - A[0])
	db(cnt)
	for i in range(N - 1):
		nextSum = sm + A[i + 1]
		db((sm, nextSum))
		if sm > 0 and nextSum >= 0:
			cnt += abs(nextSum) + 1
			sm = -1
		elif sm < 0 and nextSum <= 0:
			cnt += abs(nextSum) + 1
			sm = 1
		else:
			sm = nextSum
		db(cnt)
	return cnt

def probC():
	N = getInt()
	A = getIntList()
	db((N, A))
	if A[0] != 0:
		initSum = A[0]
	else:
		initSum = 1
	cnt1 = count(N, A, initSum)
	db(('a[0] or +1: ', cnt1))
	if initSum > 0:
		cnt2 = count(N, A, -1)
	else:
		cnt2 = count(N, A, 1)
	db(('反対符号 or -1: ', cnt2))
	return min(cnt1, cnt2)
debug = False
print(probC())


N = int(input())
A = list(map(int, input().split()))
if A[0] == 0:
	B = [1, -1]
	ANS = [1, 1]
else:
	B = [A[0], -1 * A[0] // abs(A[0])]
	ANS = [0, abs(A[0]) + 1]
for i in range(len(B)):
	b = B[i]
	for a in A[1:]:
		if a + b == 0:
			ANS[i] += 1
			b = -1 * b // abs(b)
		elif b * (a + b) < 0:
			b += a
		else:
			ANS[i] += abs(a + b) + 1
			b = -1 * (a + b) // abs(a + b)
print(min(ANS))


n = int(input())
A = list(map(int, input().split()))
s1 = 0
now = 0
for i in range(n):
	now += A[i]
	if i % 2 == 1 and now <= 0:
		s1 += 1 - now
		now = 1
	if i % 2 == 0 and now >= 0:
		s1 += now + 1
		now = -1
s2 = 0
now = 0
for i in range(n):
	now += A[i]
	if i % 2 == 0 and now <= 0:
		s2 += 1 - now
		now = 1
	if i % 2 == 1 and now >= 0:
		s2 += now + 1
		now = -1
print(min(s1, s2))


(n, *a) = map(int, open(0).read().split())
pre1 = 0
pre2 = 0
ans1 = 0
ans2 = 0
for i in range(n):
	x = (-1) ** (i % 2)
	y = -x
	pre1 += a[i]
	pre2 += a[i]
	if x * pre1 <= 0:
		ans1 += abs(pre1 - x)
		pre1 = x
	if y * pre2 <= 0:
		ans2 += abs(pre2 - y)
		pre2 = y
print(min(ans1, ans2))


def main():
	S = list(input())
	checklist = [0 for i in range(26)]
	for i in S:
		checklist[ord(i) - ord('a')] += 1
	ans = True
	for i in checklist:
		if i > 1:
			ans = False
	if not ans:
		print(-1)
		return 0
	else:
		ans = False
		for i in range(len(checklist)):
			if checklist[i] == 0:
				for i in S:
					print(i, end='')
				print(chr(i + ord('a')), end='')
				print()
				ans = True
				break
		if not ans:
			new_S = []
			for i in S:
				new_S.append(ord(i))
			for i in range(len(new_S) - 1):
				if new_S[i] > new_S[i + 1]:
					for j in range(i - 1):
						print(S[j], end='')
					print(chr(new_S[i - 1] + 1), end='')
					print()
					ans = True
					break
			if not ans:
				print(-1)

def ABC069D():
	(H, W) = map(int, input().split())
	N = int(input())
	a = list(map(int, input().split()))
	ans = []
	for i in range(N):
		for j in range(a[i]):
			ans.append(i + 1)
	printlist = [[0 for i in range(W)] for j in range(H)]
	k = 0
	for i in range(H):
		for j in range(W):
			printlist[i][j] = ans[k]
			k += 1
		if i % 2 != 0:
			printlist[i] = printlist[i][::-1]
	for i in range(H):
		for j in range(W):
			print(printlist[i][j], end='')
			if j != W:
				print(' ', end='')
		print()
	print()
import math

def cc(n, r):
	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def ABC057D():
	(N, A, B) = map(int, input().split())
	v = list(map(int, input().split()))
	v = sorted(v)[::-1]
	anslist = []
	for i in range(A, B + 1):
		anslist.append([sum(v[0:i]) / i, i, v[i - 1]])
	anslist.sort()
	anslist = anslist[::-1]
	ans = anslist[0][0]
	key = anslist[0][2]
	long = anslist[0][1]
	print(ans)
	for i in range(1, len(anslist)):
		if anslist[i][0] == anslist[i - 1][0]:
			ans = anslist[i][0]
			key = anslist[i][2]
			long = anslist[i][1]
		else:
			break
	cnt = 0
	for i in v:
		if i == key:
			cnt += 1
	c = 0
	for i in v[:long]:
		if i == key:
			c += 1
	ans = 0
	if c == long:
		for i in range(A, min(B + 1, cnt + 1)):
			ans += cc(cnt, i)
	else:
		ans = cc(cnt, c)
	print(ans)

def ABC104D():
	S = list(input())
	A_cnt = 0
	B_cnt = 0
	C_cnt = 0
	Q_cnt = 0
	ans = 0
	for i in S:
		if i == 'A':
			A_cnt += 1
		elif i == 'B':
			B_cnt += 1
		elif i == 'C':
			C_cnt += 1
		else:
			Q_cnt += 1
	for i in range(Q_cnt + 1):
		for j in range(Q_cnt - i + 1):
			k = Q_cnt - i - j
			if A_cnt + i > 0 and B_cnt + j > 0 and (C_cnt + k > 0):
				f_i = math.factorial(i)
				f_j = math.factorial(j)
				f_k = math.factorial(k)
				if f_i == 0:
					f_i = 1
				if f_j == 0:
					f_j = 1
				if f_k == 0:
					f_k = 1
				ans += (A_cnt + i) * (B_cnt + j) * (C_cnt + k) * math.factorial(Q_cnt) // f_i // f_j // f_k
				print(ans, i, j, k, A_cnt + i, B_cnt + j, C_cnt + k)
				print(math.factorial(Q_cnt), f_i, f_j, f_k)
	print(ans)

def ARC082D():
	N = int(input())
	p = list(map(int, input().split()))
	cnt = 0
	if p[N - 1] == N:
		(p[-2], p[-1]) = (p[-1], p[-2])
		cnt += 1
	for i in range(N - 1):
		if p[i] == i + 1:
			(p[i], p[i + 1]) = (p[i + 1], p[i])
			cnt += 1
	print(cnt)
from queue import Queue

def ABC070D():
	N = int(input())
	(a, b, c) = map(int, input().split())
	(Q, K) = map(int, input().split())
	xy = [list(map(int, input().split())) for i in range(Q)]
	x = [[] for i in range(N)]
	for (i, j) in xy:
		x[i - 1].append(j - 1)
		x[j - 1].append(i - 1)
	q = Queue()
	visited = [0 for i in range(N)]

def ABC076D():
	N = int(input())
	t = list(map(int, input().split()))
	v = list(map(int, input().split()))
	speed_lim = [0]
	speed_list = [0 for i in range(sum(t) + 1)]
	for i in range(N):
		for j in range(t[i]):
			speed_lim.append(v[i])
	print(speed_lim)
	for i in range(1, sum(t) + 1):
		speed_list[i] = speed_list[i - 1] + 1
		if speed_list[i] > speed_lim[i]:
			speed_list[i] = speed_lim[i]
	print(speed_list)
	speed_list[-1] = 0
	for i in range(sum(t) - 1, -1, -1):
		speed_list[i] = min(speed_list[i + 1] + 1, speed_list[i])
		if speed_list[i] > speed_lim[i + 1]:
			speed_list[i] = speed_lim[i + 1]
	print(speed_list)
	ans = 0
	for i in speed_list:
		ans += i
	print(ans)

def ABC085D():
	(N, H) = map(int, input().split())
	ab = [list(map(int, input().split())) for i in range(N)]
	a = []
	b = []
	for (i, j) in ab:
		a.append(i)
		b.append(j)
	a.sort()
	b.sort()
	a = a[::-1]
	b = b[::-1]
	damage = 0
	cnt = 0
	for i in b:
		if i < a[0]:
			break
		damage += i
		cnt += 1
		if damage >= H:
			break
	key = 0
	if damage < H:
		key = (H - damage) / a[0]
		if int(key) != key:
			key += 1
		key = int(key)
	cnt += key
	print(cnt)

def ARC068D():
	N = int(input())
	A = list(map(int, input().split()))
	A.sort()
	count_list = []
	cnt = 1
	for i in range(1, N):
		if A[i] == A[i - 1]:
			cnt += 1
		else:
			count_list.append(cnt)
			cnt = 1
	count_list.append(cnt)
	ans_cnt = 0
	for i in range(len(count_list)):
		if count_list[i] > 2:
			ans_cnt += count_list[i] % 2 - 1
			count_list[i] %= 2
			if count_list[i] == 0:
				count_list[i] = 2
	count_list = sorted(count_list)[::-1]
	for i in range(len(count_list) - 1):
		if count_list[i] == 2 and count_list[i + 1] == 2:
			ans_cnt += 1
			count_list[i] = 1
			count_list[i + 1] = 1
	count_list = sorted(count_list)[::-1]
	if count_list[0] == 2:
		count_list[0] = 0
	print(sum(count_list))

def ARC073D():
	(N, W) = map(int, input().split())
	wv = [list(map(int, input().split())) for i in range(N)]
	wv.sort()
	count_list = []
	cnt = 1
	weight_list = []
	s = 0
	g = 0
	for i in range(N - 1):
		if wv[i][0] != wv[i + 1][0]:
			g = i
			count_list.append(cnt)
			weight_list.append([wv[i][0], s, g, cnt])
			s = i + 1
			g = i + 1
			cnt = 1
		else:
			g = i
			cnt += 1
	count_list.append(cnt)
	weight_list.append([wv[-1][0], s, g, cnt])
	print(weight_list)
	wl = []
	for i in weight_list:
		this_weight = i[0]
		this_list = []
		for j in wv[i[1]:i[2] + 1]:
			this_list.append(j[1])
		this_list = sorted(this_list)[::-1]
		print(this_list)
		wl.append([this_weight, this_list])

def ARC081D():
	pattern = []
	N = int(input())
	S1 = list(input())
	S2 = list(input())
	i = 0
	while i < N:
		if S1[i] == S2[i]:
			pattern.append('X')
		else:
			pattern.append('Y')
			i += 1
		i += 1
	ans_list = []
	for i in range(len(pattern)):
		if i == 0:
			if pattern[i] == 'X':
				ans_list.append(3)
			else:
				ans_list.append(6)
		elif pattern[i] == 'X':
			if pattern[i - 1] == 'X':
				ans_list.append(2)
			else:
				ans_list.append(1)
		elif pattern[i] == 'Y':
			if pattern[i - 1] == 'X':
				ans_list.append(2)
			elif pattern[i - 1] == 'Y':
				ans_list.append(3)
	ans = 1
	for i in ans_list:
		ans *= i
	print(ans % 1000000007)

def ARC090D():
	(N, M) = map(int, input().split())
	LRD = [list(map(int, input().split())) for i in range(M)]
	L = []
	R = []
	D = []
	LRD.sort()
	root = [[] for i in range(N)]
	for (i, j, k) in LRD:
		L.append(i)
		R.append(j)
		D.append(k)
		root[i - 1].append(j - 1)
	print(root)

def ABC073D():
	(N, M, R) = map(int, input().split())
	r = list(map(int, input().split()))
	ABC = [list(map(int, input().split())) for i in range(M)]
	root = [[1000000000 for i in range(N)] for j in range(N)]
	for (i, j, k) in ABC:
		root[i - 1][j - 1] = k
		root[j - 1][i - 1] = k
	import itertools

	def kumiawase(list_name):
		return itertools.permutations(list_name)
	for i in range(N):
		for j in range(N):
			for k in range(N):
				if root[N - i - 1][N - j - 1] > root[N - i - 1][N - k - 1] + root[N - k - 1][N - j - 1]:
					root[N - i - 1][N - j - 1] = root[N - i - 1][N - k - 1] + root[N - k - 1][N - j - 1]
	a = kumiawase(r)
	ans = float('inf')
	for i in a:
		key = 0
		for j in range(len(i) - 1):
			key += root[i[j] - 1][i[j + 1] - 1]
		if ans > key:
			ans = int(key)
	print(ans)

def ARC061D():
	(H, W, N) = map(int, input().split())
	ab = [list(map(int, input().split())) for i in range(N)]
	ab.sort()
	tmp_list = []
	ans_list = [0 for i in range(10)]
	for (x, y) in ab:
		for i in range(x - 3, x):
			for j in range(y - 3, y):
				if 0 <= i < H - 2 and 0 <= j < W - 2:
					tmp_list.append([i, j])
	tmp_list.sort()
	temp = 1
	cnt = 0
	for i in range(1, len(tmp_list) + 1):
		if i != len(tmp_list):
			if tmp_list[i] == tmp_list[i - 1]:
				temp += 1
			else:
				ans_list[temp] += 1
				temp = 1
				cnt += 1
		else:
			ans_list[temp] += 1
			cnt += 1
	key = 0
	for i in range(len(ans_list)):
		key += i * ans_list[i]
	ans_list[0] = (H - 2) * (W - 2) - cnt
	for i in range(10):
		print(ans_list[i])
from scipy.sparse import csgraph

def ABC079D():
	(H, W) = map(int, input().split())
	c = [list(map(int, input().split())) for i in range(10)]
	A = [list(map(int, input().split())) for i in range(H)]
	for k in range(10):
		for i in range(10):
			for j in range(10):
				c[i][j] = min(c[i][j], c[i][k] + c[k][j])
	ans = 0
	for i in A:
		for j in i:
			if j != -1 and j != 1:
				ans += c[j][1]
	print(int(ans))
import fractions

def lcm(x, y):
	return x * y // fractions.gcd(x, y)

def AGC028A():
	(N, M) = map(int, input().split())
	S = input()
	T = input()
	key = lcm(N, M)
	n = key // N
	m = key // M
	n_list = []
	for i in range(0, key, n):
		n_list.append(i)
	m_list = []
	for j in range(0, key, m):
		m_list.append(j)
	i = 0
	j = 0
	while True:
		if i >= len(n_list) or j >= len(m_list):
			break
		if i >= len(S) or j >= len(T):
			break
		if n_list[i] == m_list[j]:
			if S[i] != T[j]:
				print(-1)
				return 0
		if n_list[i] > m_list[j]:
			j += 1
		elif n_list[i] < m_list[j]:
			i += 1
		else:
			i += 1
			j += 1
	print(key)
import math

def AGC028B():
	N = int(input())
	A = list(map(int, input().split()))
	import copy
	a = copy.deepcopy(A)
	for i in range(1, N):
		A[i] += A[i - 1]
	ans = 0
	for i in range(1, N):
		key = A[i] * 2 - A[0] - (A[i] - A[i - 1])
		ans += math.factorial(N - i) * i * key
	print(ans)
	A = copy.deepcopy(a[::-1])
	for i in range(1, N):
		A[i] += A[i - 1]
	print(A)
	for i in range(1, N):
		key = A[i] * 2 - A[0] - (A[i] - A[i - 1])
		ans += math.factorial(N - i) * i * key
	ans += A[N - 1] * math.factorial(N - 1)
	print(ans)

def AGC028B2():
	N = int(input())
	A = list(map(int, input().split()))
	import copy
	a = copy.deepcopy(A)
	for i in range(1, N):
		A[i] += A[i - 1]
	ans = 0
	for i in range(1, N):
		A[i] = A[i] * (i + 1) - A[i - 1]
	for i in range(1, N):
		ans += math.factorial(N - i) * i * A[i - 1]
	print(ans)
	ans += A[N - 1] * N
	print(ans)

def CF18QBA():
	N = int(input())
	print(100 - 100 // N)

def CF18QBB():
	(N, X) = map(int, input().split())
	ab = [list(map(int, input().split())) for i in range(N)]
	key = ab[0][1]
	ans = 0
	for (i, j) in ab:
		if j > key:
			key = j
			key2 = i
		ans += i * j
	ans += key * X
	print(ans)

def CF18QBC():
	N = int(input())
	ans_list = [[0 for i in range(N)] for j in range(N)]
	key1 = 1
	key2 = key1
	for i in range(N):
		for j in range(N):
			if key2 == j:
				ans_list[i][j] = 1
				key2 += 5
		if key1 == 1:
			key1 = 3
		elif key1 == 3:
			key1 = 0
		elif key1 == 0:
			key1 = 2
		elif key1 == 2:
			key1 = 4
		elif key1 == 4:
			key1 = 1
		key2 = key1
	cnt = 0
	for i in range(N):
		for j in range(N):
			OK = 0
			if i > 0:
				if ans_list[i - 1][j] == 1:
					OK = 1
			if i < N - 1:
				if ans_list[i + 1][j] == 1:
					OK = 1
			if j > 0:
				if ans_list[i][j - 1] == 1:
					OK = 1
			if j < N - 1:
				if ans_list[i][j + 1] == 1:
					OK = 1
			if OK == 0:
				ans_list[i][j] = 1
				1
	for i in ans_list:
		for j in i:
			if j == 0:
				print('.', end='')
			if j == 1:
				print('X', end='')
				cnt += 1
		print()

def CF18QBE():
	N = int(input())
	ans = 10000
	tmp_list = []
	key = 69720375229712477164533808935312303556800
	for i in range(1, N + 1):
		tmp_list.append([key // i, i])
	ans = tmp_list[0][0]
	cnt = 0
	ans_list = []
	ans_list.append(['+', 1])
	key = []
	while True:
		if ans < 1 / N:
			print(1)
			break
		if cnt >= 320:
			print(2)
			break
		for i in range(len(tmp_list)):
			if tmp_list[i][0] < ans:
				key = tmp_list[i]
		if key:
			ans_list.append(['-', key[1]])
		if key:
			ans -= key[0]
		key = []
		cnt += 1
	print(len(ans_list))
	for (i, j) in ans_list:
		print(i, j)

def niconicoB():
	(N, C) = map(int, input().split())
	L = [int(input()) for i in range(N)]
	L.sort()
	cnt = 0
	while len(L) > 0:
		if len(L) == 1:
			cnt += 1
			break
		if L[-1] + L[0] + 1 <= C:
			cnt += 1
			del L[0]
			del L[-1]
		else:
			cnt += 1
			del L[-1]
	print(cnt)

def ABC064D():
	N = int(input())
	S = list(input())
	cnt = 0
	start = 0
	for i in S:
		if i == '(':
			cnt += 1
		elif i == ')':
			cnt -= 1
		if cnt < 0:
			start += 1
			cnt += 1
	tmp = []
	for i in range(start):
		tmp.append('(')
	S = tmp + S
	cnt_start = 0
	cnt_end = 0
	for i in S:
		if i == '(':
			cnt_start += 1
		elif i == ')':
			cnt_end += 1
	tmp = []
	for i in range(cnt_start - cnt_end):
		tmp.append(')')
	S = S + tmp
	for i in S:
		print(i, end='')
	print()
from operator import itemgetter

def ARC072C():
	N = int(input())
	a = list(map(int, input().split()))
	cnt1 = 0
	cnt2 = 0
	sum1 = a[0]
	sum2 = a[0]
	if sum1 <= 0:
		cnt1 = 1 - a[0]
		sum1 = 1
	if sum2 >= 0:
		cnt2 = abs(-1 - a[0])
		sum2 = -1
	j = 1
	for i in range(1, N):
		sum1 += a[i]
		sum2 += a[i]
		if j % 2 == 0:
			if sum1 <= 0:
				cnt1 += 1 - sum1
				sum1 = 1
			if sum2 >= 0:
				cnt2 += abs(-1 - sum2)
				sum2 = -1
		else:
			if sum1 >= 0:
				cnt1 += abs(-1 - sum1)
				sum1 = -1
			if sum2 <= 0:
				cnt2 += 1 - sum2
				sum2 = 1
		j += 1
	print(min(cnt1, cnt2))
ARC072C()


import sys

def func(alst, sign):
	(cur, res) = (0, 0)
	for i in alst:
		cur += i
		if sign and cur <= 0:
			res += abs(cur) + 1
			cur = 1
		elif not sign and cur >= 0:
			res += abs(cur) + 1
			cur = -1
		sign = not sign
	return res

def main():
	(n, *alst) = map(int, sys.stdin.read().split())
	print(min(func(alst, True), func(alst, False)))

def __starting_point():
	main()
__starting_point()


n = int(input())
A = [int(i) for i in input().split()]
ct_1 = 0
ct_2 = 0
aa = 0
j = 1
for i in range(n):
	if (aa + A[i]) * j <= 0:
		ct_1 += abs(aa + A[i]) + 1
		aa = j
	else:
		aa += A[i]
	j *= -1
aa = 0
j = -1
for i in range(n):
	if (aa + A[i]) * j <= 0:
		ct_2 += abs(aa + A[i]) + 1
		aa = j
	else:
		aa += A[i]
	j *= -1
print(min(ct_1, ct_2))


def main():
	n = int(input())
	A = list(map(int, input().split()))
	s = 0
	c1 = 0
	for (i, a) in enumerate(A):
		s += a
		if i % 2 == 0:
			if s == 0:
				c1 += 1
			elif s < 0:
				c1 += 1 - s
			else:
				continue
			s = 1
		else:
			if s == 0:
				c1 += 1
			elif s > 0:
				c1 += s + 1
			else:
				continue
			s = -1
	s = 0
	c2 = 0
	for (i, a) in enumerate(A):
		s += a
		if i % 2 != 0:
			if s == 0:
				c2 += 1
			elif s < 0:
				c2 += 1 - s
			else:
				continue
			s = 1
		else:
			if s == 0:
				c2 += 1
			elif s > 0:
				c2 += s + 1
			else:
				continue
			s = -1
	print(min(c1, c2))

def __starting_point():
	main()
__starting_point()


n = int(input())
a = [int(x) for x in input().split()]
ret = [0, 0]
sum = [0, 0]
if a[0] == 0:
	sum[0] = 1
	ret[0] = 1
	sum[1] = -1
	ret[1] = 1
elif a[0] > 0:
	sum[0] = a[0]
	sum[1] = -1
	ret[1] = a[0] + 1
else:
	sum[0] = 1
	ret[0] = -1 * a[0] + 1
	sum[1] = a[0]
for i in range(1, n):
	for j in range(2):
		if sum[j] * (sum[j] + a[i]) < 0:
			sum[j] += a[i]
		elif sum[j] + a[i] == 0:
			if sum[j] > 0:
				sum[j] = -1
			else:
				sum[j] = 1
			ret[j] += 1
		elif sum[j] + a[i] > 0:
			ret[j] += sum[j] + a[i] + 1
			sum[j] = -1
		else:
			ret[j] += -1 * (sum[j] + a[i]) + 1
			sum[j] = 1
print(min(ret[0], ret[1]))


n = int(input())
a = [int(x) for x in input().split()]
(ans1, ans2) = (0, 0)
sum_v = 0
for i in range(len(a)):
	sum_v += a[i]
	if i % 2 == 0:
		if sum_v >= 0:
			ans1 += abs(sum_v) + 1
			sum_v = -1
	elif sum_v <= 0:
		ans1 += abs(sum_v) + 1
		sum_v = 1
sum_v = 0
for i in range(len(a)):
	sum_v += a[i]
	if i % 2 == 0:
		if sum_v <= 0:
			ans2 += abs(sum_v) + 1
			sum_v = 1
	elif sum_v >= 0:
		ans2 += abs(sum_v) + 1
		sum_v = -1
print(min(ans1, ans2))


_ = int(input())
A = list(map(int, input().split()))
ret = float('inf')
sign = 1
s = 0
k = 0
for a in A:
	if sign * (s + a) > 0:
		s += a
	else:
		k += abs(s + a) + 1
		s = sign
	sign *= -1
ret = min(ret, k)
sign = -1
s = 0
k = 0
for a in A:
	if sign * (s + a) > 0:
		s += a
	else:
		k += abs(s + a) + 1
		s = sign
	sign *= -1
ret = min(ret, k)
print(ret)


n = int(input())
arr = [int(x) for x in input().split(' ')]
ans = 0
sum = 0
curr = True
for i in range(len(arr)):
	if sum + arr[i] == 0 or (sum + arr[i] > 0) == curr:
		if curr:
			temp = -1 - sum
		else:
			temp = 1 - sum
		ans += abs(temp - arr[i])
		sum += temp
	else:
		sum += arr[i]
	curr = not curr
ans1 = 0
curr = False
sum = 0
for i in range(len(arr)):
	if sum + arr[i] == 0 or (sum + arr[i] > 0) == curr:
		if curr:
			temp = -1 - sum
		else:
			temp = 1 - sum
		ans1 += abs(temp - arr[i])
		sum += temp
	else:
		sum += arr[i]
	curr = not curr
print(min(ans, ans1))


def osilate(seq):
	flag = 1
	acc = 0
	ans = 0
	for i in range(len(seq)):
		a = seq[i]
		acc += a
		flag = i % 2
		if flag == 0:
			if acc <= 0:
				ans += 1 - acc
				acc = 1
		if flag == 1:
			if acc >= 0:
				ans += 1 + acc
				acc = -1
		flag = flag * -1
	return ans
n = int(input())
seq = [int(i) for i in input().split()]
seq_rev = [-i for i in seq]
print(min(osilate(seq), osilate(seq_rev)))


N = int(input())
A = list(map(int, input().split()))
now = 0
even_count = 0
for (i, a) in enumerate(A):
	now += a
	if i % 2 == 0 and now <= 0:
		even_count += 1 - now
		now = 1
	elif i % 2 == 1 and now >= 0:
		even_count += abs(-1 - now)
		now = -1
now = 0
odd_count = 0
for (i, a) in enumerate(A):
	now += a
	if i % 2 == 0 and now >= 0:
		odd_count += abs(-1 - now)
		now = -1
	elif i % 2 == 1 and now <= 0:
		odd_count += 1 - now
		now = 1
print(min(even_count, odd_count))


N = int(input())
a = list(map(int, input().split()))
r = 0
res = 0
for i in range(N):
	sa = 0
	r += a[i]
	if i % 2 == 0:
		if r <= 0:
			sa = 1 - r
			r += sa
	elif r >= 0:
		sa = r + 1
		r -= sa
	res += sa
r = 0
res2 = 0
for i in range(N):
	sa = 0
	r += a[i]
	if i % 2 == 1:
		if r <= 0:
			sa = 1 - r
			r += sa
	elif r >= 0:
		sa = r + 1
		r -= sa
	res2 += sa
print(min(res, res2))


import sys
sys.setrecursionlimit(10 ** 6)
_ = int(input())
A = list(map(int, input().split()))

def solve(i, s, k, sign):
	if i >= len(A):
		return k
	if sign * (s + A[i]) > 0:
		return solve(i + 1, s + A[i], k, sign * -1)
	else:
		return solve(i + 1, sign, k + abs(s + A[i]) + 1, sign * -1)
print(min(solve(0, 0, 0, 1), solve(0, 0, 0, -1)))


N = int(input())
A = [int(i) for i in input().split()]
ans = 0
s = 0
for i in range(N):
	s += A[i]
	if i % 2 == 0:
		if s <= 0:
			ans += 1 - s
			s = 1
	elif s >= 0:
		ans += s + 1
		s = -1
nums = 0
s = 0
for i in range(N):
	s += A[i]
	if i % 2 != 0:
		if s <= 0:
			nums += 1 - s
			s = 1
	elif s >= 0:
		nums += s + 1
		s = -1
print(min(nums, ans))


n = int(input())
a = list(map(int, input().split()))
if a[0] == 0:
	ans1 = 1
	tmp = 1
else:
	ans1 = 0
	tmp = a[0]
is_plus = tmp > 0
for i in range(1, n):
	tmp += a[i]
	if is_plus == (tmp > 0):
		ans1 += abs(tmp) + 1
		if is_plus:
			tmp = -1
		else:
			tmp = 1
		is_plus = tmp > 0
	else:
		is_plus = tmp > 0
ans2 = abs(a[0]) + 1
if a[0] == 0:
	ans2 = 1
	tmp = -1
else:
	ans2 = abs(a[0]) + 1
	tmp = -a[0] // abs(a[0])
is_plus = tmp > 0
for i in range(1, n):
	tmp += a[i]
	if is_plus == (tmp > 0):
		ans2 += abs(tmp) + 1
		if is_plus:
			tmp = -1
		else:
			tmp = 1
		is_plus = tmp > 0
	else:
		is_plus = tmp > 0
print(min(ans1, ans2))