CodeEff/ECCO huggingface dataset:
# Original solution
from itertools import groupby

n = eval(input())
li = list(map(int, input().split()))
lii = [val == (itr + 1) for itr, val in enumerate(li)]
gbli = [[key, len(list(group))] for key, group in groupby(lii)]
 
ans = 0
for key, val in gbli:
  if key:
    ans += (val - 1) // 2 + 1
    
print(ans)


# Optimized solution
from itertools import groupby
n = int(eval(input()))
P = list(map(int, input().split()))
T = [val == (itr + 1) for itr, val in enumerate(P)]

ans = 0
for k, v in groupby(T):
  if k == True:
    ans += (sum(v) - 1) // 2 + 1
    
print(ans)
# Original solution
n = int(eval(input()))
temp = list(map(int, input().split()))
l = [0]*n
ans = 0
for i in range(n):
  if temp[i] == i+1:
    l[i] = 0
  else:
    l[i] = 1

for i in range(n):
  if l[i] == 0 and i == n-1:
    ans += 1
  if l[i] == 0 and not i == n-1:
    l[i] = 1
    l[i+1] = 1
    ans += 1

print(ans)

# Optimized solution
n = int(eval(input()))
l = list(map(int, input().split()))
ans = 0
for i in range(n):
  if l[i] == i + 1 and i == n-1:
    ans += 1
  if l[i] == i + 1 and not i == n-1:
    l[i], l[i+1] = l[i+1], l[i]
    ans += 1
print(ans)
# Original solution
N=int(eval(input()))
p=list(map(int,input().split()))
count=0
import collections

s=collections.deque()
for i in range(N):
  if p[i]==i+1:
    s.append(i)
ans=0
while(s):
  x=s.popleft()
  if x+1 in s:
    s.popleft()
  ans+=1
  
print(ans)


# Optimized solution
N=int(eval(input()))
p=list(map(int,input().split()))
count=0
t=set()
for i in range(N):
  if p[i]==i+1:
    t.add(i)
ans=0
id=0
while(id<N):
  if id in t:
    if id+1 in t:
      id+=1
    ans+=1
  id+=1
  
  
print(ans)
# Original solution
n = int(eval(input()))
l = list(map(int,input().split()))
ans = 0
for i in range(n):
    if i != n-1:
        if i+1 == l[i]:
            a = l[i]
            b = l[i+1]
            l[i]=b
            l[i+1]=a
            ans += 1
    else:
        if i+1 == l[i]:
            ans += 1
print(ans)

# Optimized solution
n = int(eval(input()))
p = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    if i+1 == p[i]:
        p[i+1] = p[i]
        ans += 1
if p[n-1] == n:
    ans += 1
print(ans)
# Original solution
from math import ceil
n=int(eval(input()))
p=list(map(int,input().split()))
m=[]
l=[0]*n
for i in range(n):
    if p[i]==i+1:
        l[i]=1
# print(l)
t=0
for i in range(n):
    if i==n-1:
        if l[i]==1:
            t+=1
        m.append(t)
        break

    if l[i]==1:
        t+=1
        if l[i+1]==1:
            continue
        m.append(t)
        t=0
# print(m)
ans=0
for mm in m:
    ans+=ceil(mm/2)
print(ans)


# Optimized solution
n=int(eval(input()))
p=list(map(int,input().split()))
ans=0
for i in range(n-1):
  if p[i]==i+1:
    ans+=1
    x,y=p[i+1],p[i]
    p[i+1],p[i]=y,x
  if i==n-2:
    if p[-1]==n:
      ans+=1
print(ans)
# Original solution
n = int(eval(input()))
p = [int(x) for x in input().split()]

cnt = 0
for i in range(n):
    if p[i] == i + 1:
        cnt += 1
        if i != n - 1:
            p[i], p[i+1] = p[i+1], p[i]
else:
    print(cnt)

# Optimized solution
n = int(eval(input()))
p = [int(x) for x in input().split()]

skip = False
cnt = 0
for i in range(n):
    if skip:
        skip = False
    elif p[i] == i + 1:
        cnt += 1
        skip = True
else:
    print(cnt)
# Original solution
import copy

n=int(eval(input()))
f1=list(map(int,input().split()))
f2=copy.deepcopy(f1)
c=0
for i in range(n-1):
    if f1[i]==i+1:
        c+=1
        f1[i],f1[i+1]=f1[i+1],f1[i]

for i in range(n-1,0,-1):
    #print(d)
    if f1[i]==i+1:
        c+=1
        f1[i],f1[i-1]=f1[i-1],f1[i]

print(c)


# Optimized solution
n=int(eval(input()))
f=list(map(int,input().split()))
c=0
for i in range(n-1):
    if f[i]==i+1:
        c+=1
        f[i],f[i+1]=f[i+1],f[i]
if f[n-1]==n:
  	f[n-2],f[n-1]=f[n-1],f[n-2]
  	c+=1  
print(c)
# Original solution
n = int(eval(input()))
p = list(map(int, input().split())) + [0]
cnt = 0
j = False

for i in range(n):
    if p[i] == i + 1:
        cnt += 1
        if p[i + 1] == i + 2:
            if j == False:
                cnt -= 1
                j = True
            else:
                j = False
    else:
        j = False
print(cnt)

# Optimized solution
n = int(eval(input()))
p = list(map(int, input().split())) + [0]
cnt = 0
i = 0

while i < n:
    if p[i] == i + 1:
        cnt += 1
        i += 1
    i += 1

print(cnt)
# Original solution
def f(n):
    s=str(n)
    return sum([int(s[i]) for i in range(len(s))])

sunuke=[]
for i in range(16):
    for j in range(1,500):
        sunuke.append(j*(10**i)-1)

sunuke=list(set(sunuke))
sunuke.sort()
sunuke.pop(0)
L=len(sunuke)

tmp1,tmp2=sunuke[L-1],f(sunuke[L-1])
ans=[sunuke[L-1]]
for i in range(len(sunuke)-2,-1,-1):
    x=sunuke[i]
    if x*tmp2<=tmp1*f(x):
        ans.append(x)
        tmp1,tmp2=x,f(x)

ans.sort()

    

for i in range(int(eval(input()))):
    print((ans[i]))

# Optimized solution
def f(n):
    s=str(n)
    return sum([int(s[i]) for i in range(len(s))])

sunuke=[]
for i in range(16):
    for j in range(1,200):
        sunuke.append(j*(10**i)-1)

sunuke=list(set(sunuke))
sunuke.sort()
sunuke.pop(0)
L=len(sunuke)

tmp1,tmp2=sunuke[L-1],f(sunuke[L-1])
ans=[sunuke[L-1]]
for i in range(len(sunuke)-2,-1,-1):
    x=sunuke[i]
    if x*tmp2<=tmp1*f(x):
        ans.append(x)
        tmp1,tmp2=x,f(x)

ans.sort()

    

for i in range(int(eval(input()))):
    print((ans[i]))
# Original solution
import math
# import datetime

def s(n):
	sum = 0
	for c in str(n):
		sum += int(c)
	return sum

k = int(eval(input()))
found=0

def next_sunuke(n, s_n, s_n_div):

	global found

	if n == 1:
		return

	log_n = int(math.log(n,10))
	m = n - 10 ** int(log_n // 1.25)
	# m = n - 1

	while m >= 1:
		s_m = s(m)
		s_mplus1 = s(m + 1)

		# if (s_m < s_mplus1 or (s_n - s_m != 1 and s_n - s_m != -8)) and m > 9:
		if (s_m < s_mplus1) and m > 9:
			m -= 10 ** int(log_n // 1.25)
			continue

		# print("check: " + str(m))

		s_m_div = m / s(m)

		if s_m_div <= s_n_div:
			next_sunuke(m, s_m, s_m_div)
			if found >= k:
				return

			found += 1
			# print("{0:d}".format(m), "{0:+d}".format(n-m), "{0:d}".format(s_m), s_m_div)
			print(m)
			break
		# else:
		# 	log_m = int(math.log(m,10))
		# 	if (m + 1) / (10 ** (log_m - 1)) == 19:

		# 		print ("skip: " + str(m) + " to " + str(10 ** log_m - 1))

		# 		m = 10 ** log_m - 1
		# 		s_mplus1 = s(m+1)
		# 		continue

		m -= 10 ** int(log_n // 1.25)


# 適当な大きいスヌケ数
current_sunuke = 999999999999999
s_current_sunuke = s(current_sunuke)
s_current_sunuke_div = current_sunuke / s_current_sunuke

# start = datetime.datetime.now()
next_sunuke(current_sunuke, s_current_sunuke, s_current_sunuke_div)
if found < k:
	print(current_sunuke)
# end = datetime.datetime.now()
# print(str(end-start))

# sunukes=[]

# n = current_sunuke - 1

# while(n >= 1):
# 	s_n = n / s(n)
# 	if s_n <= current_sunuke_n:
# 		#sunukes.insert(0,n)
# 		sunukes.append(n)
# 		current_sunuke = n
# 		current_sunuke_n = s_n
# 	n -= 1

# for n in sunukes:
# 	print (n)


# Optimized solution
import math
# import datetime

def s(n):
	sum = 0
	for c in str(n):
		sum += int(c)
	return sum

k = int(eval(input()))
found=0

def next_sunuke(n, s_n, s_n_div):

	global found

	if n == 1:
		return

	log_n = int(math.log(n,10))
	m = n - 10 ** int(log_n // 1.25)

	while m >= 1:
		s_m = s(m)
		s_mplus1 = s(m + 1)

		if (s_m < s_mplus1 or (s_n - s_m != 1 and s_n - s_m != -8 and s_n - s_m != -17)) and m > 9:
			m -= 10 ** int(log_n // 1.25)
			continue

		# print("check: " + str(m))

		s_m_div = m / s(m)

		if s_m_div <= s_n_div:
			next_sunuke(m, s_m, s_m_div)
			if found >= k:
				return

			found += 1
			# print("{0:d}".format(m), "{0:+d}".format(n-m), "{0:d}".format(s_m), s_m_div)
			print(m)
			break


		m -= 10 ** int(log_n // 1.25)


# 適当な大きいスヌケ数
current_sunuke = 999999999999999
s_current_sunuke = s(current_sunuke)
s_current_sunuke_div = current_sunuke / s_current_sunuke

# start = datetime.datetime.now()
next_sunuke(current_sunuke, s_current_sunuke, s_current_sunuke_div)
if found < k:
	print(current_sunuke)
# end = datetime.datetime.now()
# print(str(end-start))
# Original solution
def main():
    s=set()
    for digit in range(16):
        for i in range(1,1000):
            c=i*10**digit+int('9'*digit or 0)
            if c<10**15:
                s.add(c)
    c=sorted(s)
    for i,n in enumerate(c):
        sn=n/sum(map(int,str(n)))
        for m in c[i+1:i+50]:
            sm=m/sum(map(int,str(m)))
            if sm<sn:
                s.remove(n)
                break
    print(*sorted(s)[:int(input())],sep='\n')
main()


# Optimized solution
def main():
    s=set()
    for digit in range(16):
        for i in range(1,1000):
            c=i*10**digit+int('9'*digit or 0)
            if c<10**15:
                s.add(c)
    c=sorted(s)
    for i,n in enumerate(c):
        sn=n/sum(map(int,str(n)))
        for m in c[i+1:i+20]:
            sm=m/sum(map(int,str(m)))
            if sm<sn:
                s.remove(n)
                break
    print(*sorted(s)[:int(input())],sep='\n')
main()
# Original solution
K = int(eval(input()))


def ns(n):
    return sum([int(c) for c in str(n)])


ans, base = 0, 1
for _ in range(K):
    ans += base
    print(ans)

    if (ans + base) / ns(ans + base) > (ans + 10 * base) / ns(ans + 10 * base):
        base *= 10

# Optimized solution
K = int(eval(input()))


def ns(n):
    ret, tmp = 0, n

    while tmp > 0:
        tmp, r = divmod(tmp, 10)
        ret += r

    return ret


ans, base = 0, 1
for _ in range(K):
    ans += base
    print(ans)

    if (ans + base) / ns(ans + base) > (ans + 10 * base) / ns(ans + 10 * base):
        base *= 10
# Original solution
K = int(eval(input()))


def ns(n):
    ret, tmp = 0, n

    while tmp > 0:
        tmp, r = divmod(tmp, 10)
        ret += r

    return ret


ans, base = 0, 1
for _ in range(K):
    ans += base
    print(ans)

    if (ans + base) / ns(ans + base) > (ans + 10 * base) / ns(ans + 10 * base):
        base *= 10

# Optimized solution
K = int(eval(input()))


def ns(n):
    ret, tmp = 0, n

    while tmp > 0:
        #        tmp, r = divmod(tmp, 10)
        r = tmp % 10
        tmp //= 10
        ret += r

    return ret


ans, base = 0, 1
for _ in range(K):
    ans += base
    print(ans)

    if (ans + base) / ns(ans + base) > (ans + 10 * base) / ns(ans + 10 * base):
        base *= 10
# Original solution
from math import log, floor
from itertools import islice

k = int(eval(input()))

def s(n):
    return n / sum(map(int, str(n)))

def f(n):
    ds = list(range(int(log(n+1, 10))+2))
    xs = [(10**(d+1))*floor(n/(10**(d+1)) + 1) - 1 for d in ds]
    return min(xs, key=s)

def g():
    for n in range(1, 10):
        yield n
    while True:
        n = f(n+1)
        yield n

for x in islice(g(), k):
    print(x)

# Optimized solution
from math import log, floor
from itertools import accumulate, chain, islice, repeat
 
k = int(eval(input()))
 
def f(n):
    ds = list(range(int(log(n+1, 10))+2))
    xs = [(10**(d+1))*floor(n/(10**(d+1)) + 1) - 1 for d in ds]
    return min(xs, key=lambda n:(n / sum(map(int, str(n))), n))
 
snukes = chain(list(range(1, 9)), accumulate(repeat(9), lambda x,_:f(x+1)))

for x in islice(snukes, k):
    print(x)
# Original solution
def S(i):
    ans = 0
    while i // 10 > 0:
        ans += i % 10
        i //= 10
    ans += i
    return ans

K = int(eval(input()))
Ans, count, N = [], 0, 1
while count < K:
    N2, Nd = N, 1
    while N2//10 > 0:
        Nd += 1
        N2 //= 10
    minX, X = N/S(N), N
    for i in range(Nd+2):
        x = (N//10**(i+1) + 1) * 10**(i+1) -1
        if minX > x/S(x):
            minX, X = x/S(x), x
    Ans.append((minX, X))
    count += 1
    N = X+1

for i in range(K):
    print((Ans[i][1]))

# Optimized solution
def S(i):
    ans = 0
    while i // 10 > 0:
        ans += i % 10
        i //= 10
    ans += i
    return ans

K = int(eval(input()))
count, N = 0, 1
while count < K:
    N2, Nd = N, 1
    while N2//10 > 0:
        Nd += 1
        N2 //= 10
    minX, X = N/S(N), N
    for i in range(Nd+2):
        x = (N//10**(i+1) + 1) * 10**(i+1) -1
        if minX > x/S(x):
            minX, X = x/S(x), x
    print(X)
    count += 1
    N = X+1
# Original solution
K = int(eval(input()))

P = [n for n in range(1, 10)]
Q = [n for n in range(1, 10)]
for d in range(20):
    if d < 8:
        for m in range(10, 100):
            P.append(int(str(m)+"9"*d))
            Q.append(m//10+m%10+9*d)
    else:
        for m in range(100, 1000):
            P.append(int(str(m)+"9"*(d-1)))
            Q.append(sum([int(s) for s in str(m)])+9*(d-1))

L = len(P)
c = 0
for i, (p, q) in enumerate(zip(P, Q)):
    ok = True
    for j in range(i+1, L):
        np, nq = P[j], Q[j]
        if np*q < nq*p:
            ok = False
            break
    if ok:
        print(p)
        c += 1
    if c == K:
        break


"""
import matplotlib.pyplot as plt

A = []
B = []
for n in range(-1+10**10, 10**15, 10**10):
    m = sum([int(s) for s in str(n)])
    A.append(n)
    B.append(n/m)


plt.plot(A, B)
plt.show()
"""

# Optimized solution
K = int(eval(input()))

P = [n for n in range(1, 10)]
Q = [n for n in range(1, 10)]
for d in range(20):
    if d < 12:
        for m in range(10, 100):
            P.append(int(str(m)+"9"*d))
            Q.append(m//10+m%10+9*d)
    else:
        for m in range(100, 1000):
            P.append(int(str(m)+"9"*(d-1)))
            Q.append(sum([int(s) for s in str(m)])+9*(d-1))

L = len(P)
c = 0
for i, (p, q) in enumerate(zip(P, Q)):
    ok = True
    for j in range(i+1, L):
        np, nq = P[j], Q[j]
        if np*q < nq*p:
            ok = False
            break
    if ok:
        print(p)
        c += 1
    if c == K:
        break


"""
import matplotlib.pyplot as plt

A = []
B = []
for n in range(-1+10**10, 10**14, 10**10):
    m = sum([int(s) for s in str(n)])
    A.append(n)
    B.append(n/m)


plt.plot(A, B)
plt.show()
"""
# Original solution
k = int(eval(input()))
z=1
n=1
while z<=k:
    a=1
    l=len(str(n))
    s = str(n)
    x = list(map(int, list(s)))
    while a<=l:
        if x[0]==1 and l>3:
            if l-a-1==0:
                print(n)
                a=a+100
                z=z+1
            elif n==19:
                print((19))
                a=a+100
                z=z+1
            elif x[l-a]==9:
                a=a+1
            else:
                a=a+100
        else:
            if a-l==0:
                print(n)
                a=a+100
                z=z+1
            elif n==19:
                print((19))
                a=a+100
                z=z+1
            elif x[l-a]==9:
                a=a+1
            else:
                a=a+100
    n=n+1

# Optimized solution
k = int(eval(input()))
n=0
a=1
b=0
if a==1 and n<9:
    while n<9 and b<k:
        n+=1
        print(n)
        b+=1
    a+=1
if a==2:
    while n<90 and b<k:
        n+=10
        print(n)
        b+=1
    a+=1
while b<k:
    n+=10**(a-1)
    print(n)
    b+=1
    if (n>((a-1)*10**a-10**(a-1)) and a<12) or (n>((a-2)*10**a-10**(a-1)) and a>=12):
        a+=1
# Original solution
k = eval(input())
K = int(k)
j = 1
count = 0
while True:
    a = 0
    j = str(j)
    for i in range(len(j)):
        a += int(j[i:i+1])
    j = int(j)
    if j/a < 2:
        print(j)
        count += 1
    if count == K:
        break
    j += 1

# Optimized solution
K = int(eval(input()))

a = 1
b = 0

def snk(n):
    s = 0
    for i in str(n):
        s += int(i)
    return(n/s)
    
count = 0
while True:
    print(a)
    count += 1
    if snk(a + 10 ** b) > snk(a + 10 ** (b + 1)):
        b += 1
    a += 10 ** b
    if count == K:
        break
# Original solution
import sys;input=lambda:sys.stdin.readline().rstrip();aint=lambda:int(input());ints=lambda:list(map(int,input().split()))
import math;floor,ceil=lambda x:int(math.floor(x)),lambda x:int(math.ceil(x))
from functools import reduce;gcd=lambda*x:reduce(math.gcd,x);lcm=lambda*x:reduce(lambda x,y:(x*y)//gcd(x,y),x,1)
from collections import deque
Yes=lambda b:print("Yes"if b else"No");YES=lambda b:print("YES"if b else"NO")
is_even=lambda x:True if x%2==0 else False

def main():
  s=input()
  t=input()
  n=len(s)
  flg=0
  for i in range(n):
    if s[i]!=t[i]:
      flg=1
  Yes(flg==0)

    
if __name__ == '__main__':
    main()


# Optimized solution
import sys;input=lambda:sys.stdin.readline().rstrip()
Yes=lambda b:print("Yes"if b else"No")

s,t=input(),input()
Yes(s==t[:-1])
# Original solution
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import itertools
import math
import sys

INF = float('inf')
YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str, T: str):
    return [NO, YES][len(S)+1 == len(T) and S == T[:-1]]


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    print((solve(S, T)))


if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import itertools
import math
import sys

INF = float('inf')
YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str, T: str):
    return [NO, YES][S == T[:-1]]


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    print((solve(S, T)))


if __name__ == '__main__':
    main()
# Original solution
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
import string

def main():
    s = input().rstrip()
    t = input().rstrip()
    for i in range(len(s)):
        if s[i] != t[i]:
            print("No")
            exit()
    if len(t) == len(s) +1:
        print("Yes")
    else:
        print("No")

if __name__=="__main__":
    main()


# Optimized solution
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
import string

def main():
    s = input().rstrip()
    t = input().rstrip()
    t = t[0:-1]
    if s == t:
        print("Yes")
    else:
        print("No")

if __name__=="__main__":
    main()
# Original solution
n, a, b = list(map(int, input().split()))

s_t = set()
for i in range(n):
    s_t.add(int(eval(input())))

print((len(s_t.difference(set(range(a, b))))))


# Optimized solution
n, a, b = list(map(int, input().split()))

s_t = set()
for i in range(n):
    s_t.add(int(eval(input())))
answer = 0
for s in s_t:
    if a <= s < b:
        pass
    else:
        answer += 1
print(answer)
# Original solution
n, a ,b = list(map(int, input().split()))
c = 0
for i in range(n):
    t = eval(input())
    if not t in range(a,b):
        c += 1
print(c)

# Optimized solution
n, a ,b = list(map(int, input().split()))
c = 0
for i in range(n):
    t = eval(input())
    if not a <= t < b:
        c += 1
print(c)
# Original solution
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created:  2016-10-07
#

# Usage
#
"""





def read():
    """Read like as below.
    N A B
    t_1
    t_n
    """
    line_1 = input().split(" ")
    num_of_class = int(line_1[0])
    blocked_class = line_1[1:2]
    blocked_class = list(range(int(line_1[1]), int(line_1[2])))

    following_class = [int(eval(input())) for _ in range(num_of_class)]

    return following_class, blocked_class


def check_available_class(following_class, blocked_class):
    """Check how many class you can attend.
    >>> check_available_class([4,3,6,9,1], [5,6,7,8])
    4
    >>> check_available_class([5,6,7,8,9], [4,5,6,7,8])
    1
    """
    return len(set(following_class).difference(set(blocked_class)))


if __name__ == "__main__":
    f, b = read()
    print(check_available_class(f,b))


# Optimized solution
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created:  2016-10-07
#

# Usage
#
"""
def read():
    """Read like as below.
    N A B
    t_1
    t_n
    """
    line_1 = input().split(" ")
    num_of_class = int(line_1[0])
    blocked_class = line_1[1:2]
    blocked_class = list(range(int(line_1[1]), int(line_1[2])))

    following_class = {int(eval(input())) for _ in range(num_of_class)}

    return following_class, blocked_class


def check_available_class(following_class, blocked_class):
    """Check how many class you can attend.
    >>> check_available_class([4,3,6,9,1], [5,6,7,8])
    4
    >>> check_available_class([5,6,7,8,9], [4,5,6,7,8])
    1
    """
    return len(set(following_class).difference(blocked_class))


if __name__ == "__main__":
    f, b = read()
    print((check_available_class(f,b)))
# Original solution
import copy

n = int(eval(input()))
a = list(map(int,input().split()))
b = [0]

for i in range(len(a)):
    b.append(b[i] + a[i])

del b[0]

c = copy.copy(b)

first_minus = 0
first_plus = 0

for i in range(len(b)):
    if(i%2 == 0):
        if (b[i] >= 0):
            diff =  abs(b[i]) + 1
            first_minus = first_minus +  diff
            b = list([x - diff for x in b])

        if (c[i] <= 0):
            diff =  abs(c[i]) + 1
            first_plus = first_plus +  diff
            c = list([x + diff for x in c])
    else:
        if (b[i] <= 0):
            diff =  abs(b[i]) + 1
            first_minus = first_minus +  diff
            b = list([x + diff for x in b])

        if (c[i] >= 0):
            diff =  abs(c[i]) + 1
            first_plus = first_plus +  diff
            c = list([x - diff for x in c])

print((min(first_minus,first_plus)))

# Optimized solution
import copy

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

ans_a = 0
for i in range(len(a)):
    sum += a[i]
    if(i%2 == 0):
        if(sum >= 0):
            ans_a += sum + 1
            sum = -1
    else:
        if(sum <= 0):
            ans_a += 1 - sum
            sum = 1

sum = 0
ans_b = 0
for i in range(len(a)):
    sum += a[i]
    if(i%2 == 0):
        if(sum <= 0):
            ans_b += 1 - sum
            sum = 1
    else:
        if(sum >= 0):
            ans_b += sum + 1
            sum = -1

print((min(ans_a,ans_b)))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
b=[]
for i in range(n):
  b.append(a[i])

ct1=0
if a[0]<=0:
  a[0]=1
  ct1+=1-a[0]
for i in range(1,n):
  if i%2==1:
    if sum(a[0:i+1])>=0:
      ct1+=sum(a[0:i+1])+1
      a[i]=-sum(a[0:i])-1
  else:
    if sum(a[0:i+1])<=0:
      ct1+=1-sum(a[0:i+1])
      a[i]=-sum(a[0:i])+1

ct2=0
if b[0]>=0:
  b[0]=-1
  ct2+=b[0]-1
for i in range(1,n):
  if i%2==0:
    if sum(b[0:i+1])>=0:
      ct2+=sum(b[0:i+1])+1
      b[i]=-sum(b[0:i])-1
  else:
    if sum(b[0:i+1])<=0:
      ct2+=1-sum(b[0:i+1])
      b[i]=-sum(b[0:i])+1

print((min(ct1,ct2)))

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
b=[]
for i in range(n):
  b.append(a[i])

ct1=0
if a[0]<=0:
  ct1+=1-a[0]
  a[0]=1
x=a[0]
for i in range(1,n):
  y=x+a[i]
  if i%2==1:
    if y>=0:
      ct1+=y+1
      a[i]=-x-1
  else:
    if y<=0:
      ct1+=1-y
      a[i]=-x+1
  x+=a[i]

ct2=0
if b[0]>=0:
  ct2+=b[0]+1
  b[0]=-1
x=b[0]
for i in range(1,n):
  y=x+b[i]
  if i%2==0:
    if y>=0:
      ct2+=y+1
      b[i]=-x-1
  else:
    if y<=0:
      ct2+=1-y
      b[i]=-x+1
  x+=b[i]

print((min(ct1,ct2)))