You are the benevolent ruler of Rankhacker Castle, and today you're distributing bread.  Your subjects are in a line, and some of them already have some loaves.  Times are hard and your castle's food stocks are dwindling, so you must distribute as few loaves as possible according to the following rules:

Every time you give a loaf of bread to some person $\boldsymbol{i}$, you must also give a loaf of bread to the person immediately in front of or behind them in the line (i.e., persons $i+1$ or $i-1$).    
After all the bread is distributed, each person must have an even number of loaves.

Given the number of loaves already held by each citizen, find and print the minimum number of loaves you must distribute to satisfy the two rules above. If this is not possible, print NO.

Example 

$B=[4,5,6,7]$    

We can first give a loaf to $i=3$ and $i=4$ so $B=[4,5,7,8]$.   
Next we give a loaf to $i=2$ and $i=3$ and have $B=[4,6,8,8]$ which satisfies our conditions.    

All of the counts are now even numbers.  We had to distribute $4$ loaves.  

Function Description  

Complete the fairRations function in the editor below.  

fairRations has the following parameter(s):  

int B[N]: the numbers of loaves each persons starts with   

Returns   

string:  the minimum number of loaves required, cast as a string, or 'NO'

Input Format

The first line contains an integer $N$, the number of subjects in the bread line.  

The second line contains $N$ space-separated integers $B[i]$.

Constraints

$2\leq N\leq1000$  
$1\leq B[i]\leq10$, where $1\leq i\leq N$  

Output Format

Sample Input 0  

STDIN       Function
-----       --------
5           B[] size N = 5
2 3 4 5 6   B = [2, 3, 4, 5, 6]   

Sample Output 0  

4

Explanation 0

The initial distribution is $(2,3,4,5,6)$. The requirements can be met as follows:  

Give $1$ loaf of bread each to the second and third people so that the distribution becomes $(2,4,5,5,6)$.  
Give $\mbox{I}$ loaf of bread each to the third and fourth people so that the distribution becomes $(2,4,6,6,6)$.  

Each of the $N$ subjects has an even number of loaves after $4$ loaves were distributed.

Sample Input 1  

2
1 2

Sample Output 1  

NO

Explanation 1

The initial distribution is $(1,2)$. As there are only $2$ people in the line, any time you give one person a loaf you must always give the other person a loaf. Because the first person has an odd number of loaves and the second person has an even number of loaves, no amount of distributed loaves will ever result in both subjects having an even number of loaves.

Difficulty: EASY

Solutions:
import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
ans = 0
for i in range(len(B) - 1):
	if B[i] & 1:
		B[i + 1] += 1
		ans += 2
if B[-1] & 1:
	print('NO')
else:
	print(ans)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
start = sum(B)
if start % 2 == 1:
	print('NO')
else:
	for (i, x) in enumerate(B):
		if x % 2 == 1:
			B[i] += 1
			B[i + 1] += 1
	print(sum(B) - start)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
if sum(B) % 2 == 1:
	print('NO')
else:
	b = 0
	for i in range(N):
		if B[i] % 2 == 1:
			B[i + 1] += 1
			b += 2
	print(b)


import sys
N = int(input().strip())
B = [int(B_temp) & 1 for B_temp in input().strip().split(' ')]
g = 0
for i in range(N):
	if B[i]:
		if i == N - 1:
			g = -1
			break
		else:
			g += 2
			B[i + 1] ^= 1
print(g if g != -1 else 'NO')


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
R = 0
for i in range(N):
	if B[i] % 2 != 0:
		B[i] += 1
		if i + 1 < N:
			B[i + 1] += 1
		else:
			print('NO')
			break
		R += 2
else:
	print(R)


import sys

def answer(n, b):
	ones = sum(b)
	if ones % 2 == 1:
		return 'NO'
	ans = 0
	adding = False
	distance = 0
	curr = 0
	while curr < n and ones > 0:
		if b[curr] == 1:
			if adding:
				distance += 1
				adding = False
				ans += 2 * distance
				distance = 0
				ones -= 1
			else:
				adding = True
				ones -= 1
		elif adding:
			distance += 1
		curr += 1
	return ans
N = int(input().strip())
B = [int(B_temp) % 2 for B_temp in input().strip().split(' ')]
print(answer(N, B))


N = int(input())
B = [int(B_temp) % 2 for B_temp in input().split()]
if sum(B) % 2 == 1:
	print('NO')
else:
	c = 0
	while 1 in B:
		i = B.index(1)
		j = B.index(1, i + 1)
		c += j - i
		B[i] = B[j] = 0
	print(2 * c)


import sys
N = int(input().strip())
B = [int(B_temp) % 2 for B_temp in input().strip().split(' ')]
cnt = 0
for i in range(N - 1):
	if B[i]:
		(B[i], B[i + 1]) = (0, 1 - B[i + 1])
		cnt += 2
if B[-1]:
	print('NO')
else:
	print(cnt)


def fun(a, n):
	ans = 0
	for i in range(n - 1):
		if a[i] % 2 == 1:
			a[i] += 1
			a[i + 1] += 1
			ans += 2
	if a[n - 1] % 2 == 1:
		return -1
	else:
		return ans
n = int(input())
a = [int(i) for i in input().split()]
ans = fun(a, n)
if ans >= 0:
	print(ans)
else:
	print('NO')


import sys
n = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
total = 0
for i in range(n):
	if B[i] % 2 == 1:
		B[i] += 1
		if i + 1 >= n:
			B[i - 1] += 1
		else:
			B[i + 1] += 1
		total += 2
if any([x % 2 == 1 for x in B]):
	print('NO')
else:
	print(total)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
loaves = 0
for i in range(N - 1):
	if B[i] % 2 == 1:
		B[i] += 1
		B[i + 1] += 1
		loaves += 2
oddFlag = False
for i in range(N):
	if B[i] % 2 == 1:
		oddFlag = True
		break
if not oddFlag:
	print(loaves)
else:
	print('NO')


import sys
N = int(input().strip())
B = [int(B_temp) % 2 for B_temp in input().strip().split(' ')]
res = 0
for i in range(N - 1):
	if B[i] == 1:
		B[i] ^= 1
		B[i + 1] ^= 1
		res += 2
	else:
		pass
if B[N - 1] == 0:
	print(res)
else:
	print('NO')


import sys

def solve(b):
	if sum(b) % 2 == 1:
		return 'NO'
	tot = 0
	for i in range(len(b) - 1):
		if b[i] % 2 == 1:
			b[i] = b[i] + 1
			b[i + 1] = b[i + 1] + 1
			tot = tot + 2
	return tot
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
print(solve(B))


def main():
	n = int(input())
	(l, ans) = ([(int(i) + 2) % 2 for i in input().split()], 0)
	(c, pos) = (l.count(1), [])
	for (i, ii) in enumerate(l):
		if ii == 1:
			pos.append(i)
	if c % 2:
		print('NO')
	else:
		for i in range(0, len(pos), 2):
			(n1, n2) = (pos[i], pos[i + 1])
			ans += (n2 - n1) * 2
		print(ans)
main()


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]

def number_of_distributions(N, B_array):
	distributions = 0
	length = len(B_array)
	for i in range(len(B_array)):
		if B_array[i] % 2 != 0:
			if i == length - 1:
				return -1
			B_array[i] += 1
			B_array[i + 1] += 1
			distributions += 2
	return distributions
result = number_of_distributions(N, B)
if result == -1:
	print('NO')
else:
	print(result)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
count = 0
carry = 0
for b in B:
	b = b + carry
	if b % 2 == 0:
		carry = 0
	else:
		carry = 1
		count = count + 2
if carry == 1:
	print('NO')
else:
	print(count)


import sys
loaves = 0
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
even = [int(elem % 2 == 0) for elem in B]
NO = False
for i in range(N):
	if not even[i] and i != N - 1:
		even[i + 1] = not even[i + 1]
		loaves += 2
	if i == N - 1 and (not even[i]):
		NO = True
if NO:
	print('NO')
else:
	print(loaves)


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

def cost(seq):
	c = 0
	for i in range(len(seq) - 1):
		if seq[i] & 1:
			c += 2
			seq[i] += 1
			seq[i + 1] += 1
	return 10 ** 5 if seq[-1] & 1 else c
c = min(cost(b[:]), cost(b[::-1]))
print('NO' if c == 10 ** 5 else c)


from sys import stderr

def readlist(f):
	return [f(x) for x in input().split()]
N = int(input())
B = readlist(int)
odd_indices = [i for (i, Bi) in enumerate(B) if Bi % 2 == 1]
given = 0
if len(odd_indices) % 2 == 1:
	print('NO')
else:
	for j in range(0, len(odd_indices), 2):
		i0 = odd_indices[j]
		i1 = odd_indices[j + 1]
		given += i1 - i0
	print(2 * given)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
numOdd = 0
numEven = 0
for i in B:
	if i % 2 == 0:
		numEven += 1
	else:
		numOdd += 1
total = 0
for i in range(len(B)):
	if B[i] % 2 == 0:
		continue
	else:
		for j in range(i + 1, len(B)):
			if B[j] % 2 == 1:
				total += (j - i) * 2
				B[j] += 1
				B[i] += 1
				break
if numOdd % 2 == 1:
	print('NO')
else:
	print(total)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
loaves = 0
odds = [num for num in B if num % 2 != 0]
if len(odds) % 2 != 0:
	print('NO')
else:
	for (index, num) in enumerate(B):
		if num % 2 != 0:
			if index == len(B) - 1:
				print('NO')
			else:
				loaves += 2
				B[index] += 1
				B[index + 1] += 1
	print(loaves)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
count = 0
oneback = 0
twoback = 0
for x in B:
	if oneback == 0:
		if twoback == 1:
			if x % 2:
				count += 4
				twoback = 0
				oneback = 0
				continue
			else:
				count += 4
				twoback = 0
				oneback = 1
				continue
		else:
			pass
	elif x % 2:
		count += 2
		twoback = 0
		oneback = 0
		continue
	twoback = oneback
	oneback = 1 if x % 2 else 0
else:
	if oneback == 0 and twoback == 0:
		print(count)
	else:
		print('NO')


n = int(input())
s = 0
l = []
l[:] = map(int, input().split())
s = sum(l)
if s % 2 == 1:
	print('NO')
else:
	count = 0
	for i in range(n):
		if l[i] % 2 == 1:
			l[i] = l[i] + 1
			l[i + 1] = l[i + 1] + 1
			count += 2
	print(count)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
count = 0
binar = []
for x in B:
	binar.append(x % 2)
last = len(binar) - 1
for i in range(last):
	if binar[i] > 0:
		binar[i] = 0
		count += 2
		binar[i + 1] = (binar[i + 1] + 1) % 2
if binar[-1] > 0:
	print('NO')
else:
	print(count)


import sys
n = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
loaves_given = 0
for i in range(n):
	if B[i] % 2 == 1:
		if i == n - 1:
			print('NO')
			break
		B[i] += 1
		B[i + 1] += 1
		loaves_given += 2
else:
	print(loaves_given)


import sys

def bread_distribution(n, b):
	if sum(b) % 2 != 0:
		return 'NO'
	else:
		count = 0
		for i in range(n - 1):
			if b[i] % 2 != 0:
				count += 1
				b[i] += 1
				b[i + 1] += 1
		if b[n - 1] % 2 == 0:
			return 2 * count
		else:
			return 'NO'
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
print(bread_distribution(N, B))


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]

def solve(B, N):
	iWithOdd = [i for i in range(len(B)) if B[i] % 2 != 0]
	if len(iWithOdd) % 2 != 0 or len(iWithOdd) > N:
		return -1
	n = 0
	for i in range(0, len(iWithOdd), 2):
		n += (iWithOdd[i + 1] - iWithOdd[i]) * 2
	return n
result = solve(B, N)
print(result if result >= 0 else 'NO')


import sys

def countzero(ls):
	c = 0
	for i in range(len(ls)):
		if ls[i] == 0:
			c += 1
	return c
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
lst = [0] * N
for i in range(N):
	if B[i] % 2 == 0:
		lst[i] = 1
count = 0
for i in range(N):
	if lst[i] == 0:
		count += 1
		lst[i] = 1
		if lst[i + 1] == 1:
			lst[i + 1] = 0
		else:
			lst[i + 1] = 1
	if countzero(lst) == 1:
		print('NO')
		exit()
print(2 * count)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
k = 0
while k < N and B[k] % 2 == 0:
	k += 1
nb = 0
for i in range(k, N - 1):
	if B[i] % 2 == 1:
		nb += 2
		B[i] += 1
		B[i + 1] += 1
if B[-1] % 2 == 1:
	print('NO')
else:
	print(nb)


N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
ans = 0
if N > 2:
	for i in range(len(B) - 1):
		if B[i] % 2 != 0:
			B[i] += 1
			B[i + 1] += 1
			ans += 2
	if all((x % 2 == 0 for x in B)):
		print(ans)
	else:
		print('NO')
elif all((x % 2 == 0 for x in B)):
	print('0')
elif all((x % 2 != 0 for x in B)):
	print('1')
else:
	print('NO')


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
C = [0] * N
loafGiven = 0
first = -1
second = -1
oddCount = 0
for i in range(N):
	if B[i] % 2 == 1:
		oddCount += 1
		if first == -1:
			first = i
		elif second == -1:
			second = i
if oddCount == 0:
	print('0')
elif oddCount % 2 == 1:
	print('NO')
else:
	while oddCount != 0:
		B[first] += 1
		if first > second:
			B[first - 1] += 1
		else:
			B[first + 1] += 1
		loafGiven += 2
		first = -1
		second = -1
		oddCount = 0
		for i in range(N):
			if B[i] % 2 == 1:
				oddCount += 1
				if first == -1:
					first = i
				elif second == -1:
					second = i
	print(loafGiven)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
odd_idx = []
for (i, b) in enumerate(B):
	if b & 1 == 1:
		odd_idx.append(i)
if len(odd_idx) & 1 == 1:
	print('NO')
else:
	count = 0
	for i in range(0, len(odd_idx), 2):
		count += odd_idx[i + 1] - (odd_idx[i] + 1)
	count += len(odd_idx) // 2
	print(2 * count)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
loaves = 0
for i in range(len(B) - 1):
	if B[i] % 2 != 0:
		loaves += 2
		B[i] += 1
		B[i + 1] += 1
if B[-1] % 2 == 0:
	print(loaves)
else:
	print('NO')


def sodd(arr):
	flag = 0
	for k in arr:
		if k % 2 != 0:
			flag = 1
			return arr.index(k)
			break
	if flag == 0:
		return -1

def nearr(arr, k):
	if k > 0 and k <= len(arr) - 2:
		if arr[k - 1] % 2 != 0:
			return k - 1
		elif arr[k + 1] % 2 != 0:
			return k + 1
		else:
			flag = 0
			j = k
			while k <= len(arr) - 2:
				if arr[k + 1] % 2 != 0:
					flag = 1
					return j + 1
					break
				k += 1
			if flag == 0:
				while k > 0:
					if arr[k - 1] % 2 != 0:
						flag = 1
						return j - 1
						break
					k += 1
	elif k == len(arr) - 1:
		return k - 1
	elif k == 0:
		return k + 1
nn = int(input().strip())
arr = [int(B_temp) for B_temp in input().strip().split(' ')]
if sum(arr) % 2 != 0:
	print('NO')
else:
	res = 0
	kk = sodd(arr)
	while kk != -1:
		nnkk = nearr(arr, kk)
		arr[kk] += 1
		arr[nnkk] += 1
		res += 2
		kk = sodd(arr)
	print(res)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
cnt = 0
for i in range(N):
	if B[i] % 2 == 0:
		continue
	elif i < len(B) - 1:
		B[i] += 1
		B[i + 1] += 1
		cnt += 2
	else:
		cnt = 'NO'
print(cnt)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]

def is_odd(number):
	return number % 2 != 0
odds = [x for x in B if is_odd(x)]
if is_odd(len(odds)):
	print('NO')
else:
	quantity = 0
	for i in range(0, len(B) - 1):
		if is_odd(B[i]):
			B[i] += 1
			B[i + 1] += 1
			quantity += 2
	print(quantity)


n = int(input())
B = [int(i) for i in input().strip().split()]
c = 0
for i in range(n - 1):
	if B[i] & 1:
		B[i + 1] += 1
		c += 2
if B[-1] & 1:
	print('NO')
else:
	print(c)


n = int(input())
a = list(map(int, input().split()))
c = 0
for i in range(n - 1):
	if a[i] & 1:
		a[i + 1] += 1
		c += 2
print('NO' if a[-1] & 1 else c)


N = int(input())
B = [int(x) for x in input().split()]
tot = 0
num = 0
for x in B:
	tot += x
	num += tot & 1
print('NO' if tot & 1 else num << 1)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
o = 0
for i in range(N - 1):
	if B[i] % 2 == 1:
		B[i + 1] += 1
		o += 1
if B[N - 1] % 2 == 1:
	print('NO')
else:
	print(o * 2)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]

def solve(b):
	cache = [v % 2 for v in b]
	print(cache, file=sys.stderr)
	(i, l) = (0, len(cache))
	cnt = 0
	while i < l - 1:
		if cache[i] == 1:
			for j in range(i, i + 2):
				cache[j] = (cache[j] + 1) % 2
				cnt += 1
			print(cache, file=sys.stderr)
		i += 1
	if cache[-1] == 1:
		return -1
	return cnt
v = solve(B)
if v == -1:
	print('NO')
else:
	print(v)


def read_ints():
	return [int(x) for x in input().strip().split(' ')]

def read_int():
	v = read_ints()
	return v[0]
N = read_int()
breads = read_ints()
num_breads = 0
for i in range(len(breads) - 1):
	if breads[i] % 2 == 1:
		breads[i] += 1
		breads[i + 1] += 1
		num_breads += 2
if breads[-1] % 2 == 1:
	num_breads = 'NO'
print(num_breads)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
k = True
l = 0
while k:
	k = False
	odds = [num for num in B if num % 2]
	if len(odds) % 2:
		l = 'NO'
	else:
		for (key, value) in enumerate(B):
			if value % 2:
				k = True
				l += 2
				B[key] += 1
				if key == 0:
					B[key + 1] += 1
				elif key == N - 1:
					B[key - 1] += 1
				elif B[key + 1] % 2:
					B[key + 1] += 1
				elif B[key - 1] % 2:
					B[key - 1] += 1
				elif B[key - 1] % 2 == 0 and B[key + 1] % 2 == 0:
					B[key + 1] += 1
print(l)


n = int(input())
arr = [int(x) for x in input().split()]
given = 0
for i in range(len(arr) - 1):
	if arr[i] % 2 == 1:
		arr[i] += 1
		arr[i + 1] += 1
		given += 2
if arr[-1] % 2 == 0:
	print(given)
else:
	print('NO')


import sys
im = []
br = 0
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
for i in range(N):
	if B[i] % 2 == 1:
		im.append(i)
if len(im) % 2 == 0:
	for i in range(0, len(im) - 1, 2):
		br += (im[i + 1] - im[i]) * 2
	print(br)
else:
	print('NO')


import sys
N = int(input().strip())
mk = 0
for B_temp in input().strip().split(' '):
	mk = 2 * mk + (int(B_temp) & 1)
cnt = 0
while mk > 1:
	if mk & 1:
		mk = mk >> 1 ^ 1
		cnt += 2
	else:
		mk >>= 1
print(cnt if not mk else 'NO')


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
if sum(B) & 1:
	print('NO')
else:
	i = 0
	d = 0
	while i < len(B):
		if B[i] & 1:
			B[i] += 1
			B[i + 1] += 1
			d += 2
		else:
			i += 1
	print(d)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
breads = 0
for i in range(len(B) - 1):
	if B[i] % 2 != 0:
		B[i + 1] += 1
		breads += 2
print(breads if B[-1] % 2 == 0 else 'NO')


import sys
n = int(input().strip())
arr = [int(B_temp) for B_temp in input().strip().split(' ')]
bread = 0
indexList = []

def countOdd(arr):
	count = 0
	for i in range(n):
		if not isEven(arr[i]):
			count += 1
			indexList.append(i)
	return count

def isEven(n):
	if n % 2 != 0:
		return False
	return True
if isEven(countOdd(arr)):
	for i in range(0, len(indexList), 2):
		bread += 1 + 2 * (indexList[i + 1] - indexList[i] - 1) + 1
	print(bread)
else:
	print('NO')


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]

def all_even(lst):
	evens = 0
	for x in lst:
		if x % 2 == 0:
			evens += 1
	if evens == len(lst):
		return True
	else:
		return False
loaves = 0
possible = True
while all_even(B) == False and len(B) > 2 and (possible == True):
	for x in range(N - 1):
		if B[x] % 2 != 0:
			B[x] += 1
			B[x + 1] += 1
			loaves += 2
	if not all_even(B):
		print('NO')
		possible = False
		break
if len(B) < 3:
	print('NO')
elif possible == True:
	print(loaves)


import sys
n = int(input().strip())
arr = [int(B_temp) for B_temp in input().strip().split(' ')]
if sum(arr) % 2 == 1:
	print('NO')
else:
	ans = 0
	for i in range(0, len(arr)):
		if arr[i] % 2 == 0:
			continue
		ans += 2
		arr[i + 1] += 1
	print(ans)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
givebread = 0
for n1 in range(N - 1):
	if B[n1] % 2 == 1:
		B[n1] += 1
		B[n1 + 1] += 1
		givebread += 2
if B[N - 1] % 2 == 1:
	givebread = 'NO'
print(givebread)


import sys
n = int(input().strip())
b = [int(B_temp) for B_temp in input().strip().split(' ')]
tot = 0
for i in range(0, n - 1):
	if b[i] % 2 != 0:
		(b[i], b[i + 1]) = (b[i] + 1, b[i + 1] + 1)
		tot = tot + 2
if b[n - 1] % 2 == 0:
	print(tot)
else:
	print('NO')


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
r = 0
possible = True
for (ind, nbPain) in enumerate(B):
	if nbPain % 2 != 0:
		r += 2
		try:
			B[ind + 1] += 1
		except:
			possible = False
if possible:
	print(r)
else:
	print('NO')


def give_loaves(B):
	B[0] += 1
	B[1] += 1
	return B

def trim_odd(B):
	while len(B) > 0 and B[0] % 2 == 0:
		B.pop(0)
	while len(B) > 0 and B[-1] % 2 == 0:
		B.pop()
	return B

def fair_rations(B):
	loaves = 0
	while True:
		B = trim_odd(B)
		if len(B) == 0:
			return loaves
		elif len(B) == 1:
			return 'NO'
		else:
			B = give_loaves(B)
			loaves += 2
n = int(input())
B = [int(b) for b in input().split(' ')]
print(fair_rations(B))


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
count = 0
for i in range(N - 1):
	if B[i] % 2 == 1:
		B[i] += 1
		B[i + 1] += 1
		count += 2
if sum(B) % 2 == 0:
	print(count)
else:
	print('NO')


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
sum_B = sum(B)
if sum_B % 2 != 0:
	print('NO')
else:
	for i in range(len(B) - 1):
		if B[i] % 2 != 0:
			B[i] += 1
			B[i + 1] += 1
	sum_B_final = sum(B)
	print(sum_B_final - sum_B)


import sys
(EVEN, ODD) = (0, 1)

def swap_parity(par):
	return [EVEN, ODD][par is EVEN]
N = int(input())
B = [[EVEN, ODD][int(B_temp) % 2] for B_temp in input().split()]
if sum((1 for x in B if x is ODD)) % 2 == 1:
	print('NO')
	sys.exit()
loaves = 0
for i in range(N):
	if B[i] is ODD:
		B[i] = EVEN
		B[i + 1] = swap_parity(B[i + 1])
		loaves += 2
print(loaves)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
c = 0
for i in range(N - 1):
	if B[i] % 2 != 0:
		c += 2
		B[i] += 1
		B[i + 1] += 1
if not all((x % 2 == 0 for x in B)):
	print('NO')
else:
	print(c)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
loafs = 0
for i in range(N - 1):
	if B[i] % 2 == 1:
		B[i + 1] += 1
		loafs += 2
if B[-1] % 2 == 0:
	print(loafs)
else:
	print('NO')


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
if sum(B) % 2 != 0:
	print('NO')
else:
	count = 0
	C = []
	for i in B:
		C.append(i % 2)
	for i in range(len(C)):
		if C[i] % 2 != 0:
			C[i + 1] += 1
			count += 2
	print(count)


def f(x):
	return x % 2
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split()]
a = list(map(f, B))
o = sum(a)
if f(o) != 0:
	print('NO')
else:
	d = 0
	rem = o / 2
	i = 0
	while rem > 0:
		j = 1
		if a[i] != 0:
			while a[i + j] == 0:
				j += 1
			rem -= 1.0
			d += j
			j += 1
		i += j
	print(2 * d)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
answer = 0
for i in range(0, len(B) - 1):
	if B[i] % 2 == 1:
		answer += 2
		B[i] += 1
		B[i + 1] += 1
if B[-1] % 2 == 1:
	print('NO')
else:
	print(answer)


import sys
n = int(input().strip())
b = [int(bt) % 2 for bt in input().strip().split(' ')]
loaves = 0
if sum((bi == 1 for bi in b)) & 1:
	print('NO')
else:
	for i in range(len(b)):
		if b[i]:
			b[i + 1] = (b[i + 1] + 1) % 2
			loaves += 2
	print(loaves)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
s = sum(B)
if s % 2 != 0:
	print('NO')
else:
	l = 0
	first_odd_index = -1
	second_odd_index = -1
	for i in range(0, N):
		b = B[i]
		if b % 2 != 0:
			if first_odd_index == -1:
				first_odd_index = i
			else:
				d = i - first_odd_index
				l_i = 2 * d
				l += l_i
				first_odd_index = -1
	print(l)


n = int(input())
l = list(map(int, input().split()))
count = 0
for i in range(len(l) - 1):
	if l[i] % 2 == 1:
		l[i] += 1
		l[i + 1] += 1
		count += 2
if l[-1] % 2 == 0:
	print(count)
else:
	print('NO')


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
count = 0
i = 0
while i < len(B):
	num = B[i]
	if num % 2 == 1 and i != len(B) - 1:
		B[i] += 1
		B[i + 1] += 1
		count += 2
	i += 1
for check in B:
	if check % 2 == 1:
		print('NO')
		sys.exit()
print(count)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
res = 0
for i in range(N - 1):
	if B[i] % 2 == 1:
		B[i] = 0
		B[i + 1] = B[i + 1] % 2 + 1
		res += 2
if B[N - 1] % 2 == 1:
	print('NO')
else:
	print(res)


input()
subjects = map(int, input().strip().split(' '))
total_loaves = 0
carry = 0
for subj in subjects:
	if (subj + carry) % 2 == 1:
		carry = 1
		total_loaves += 2
	else:
		carry = 0
print(total_loaves if carry == 0 else 'NO')


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
c = 0
if sum(B) % 2:
	print('NO')
else:
	for i in range(N - 1):
		if B[i] % 2:
			B[i] += 1
			B[i + 1] += 1
			c += 2
	print(c)


import sys
n = int(input())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
total_odd = 0
t = 0
count = 0
lst = [B[0] % 2]
if lst[0] == 0:
	lst[0] = -1
else:
	total_odd += 1
prev = lst[0]
for btemp in B[1:]:
	t = btemp % 2
	if t == 0:
		t = -1
	else:
		total_odd += 1
	if t == prev:
		lst[-1] += t
	else:
		prev = t
		lst += [t]
if total_odd % 2 == 1:
	print('NO')
	exit()
length = len(lst)
for (i, val) in enumerate(lst):
	if val > 0 and val % 2 == 1 and (i + 2 < length):
		lst[i] = lst[i] - 1
		lst[i + 2] = lst[i + 2] + 1
		count -= lst[i + 1]
for val in lst:
	if val > 0 and val % 2 == 1:
		print('NO')
		exit()
print(count * 2 + total_odd)


import sys
n = int(input().strip())
b = [int(B_temp) for B_temp in input().strip().split(' ')]
ekmek = 0
sayac = 0
for j in range(len(b) - 1):
	if b[j] % 2 != 0:
		b[j] += 1
		ekmek += 1
		b[j + 1] += 1
		ekmek += 1
for k in range(len(b)):
	if b[k] % 2 == 1:
		print('NO')
		break
	else:
		sayac += 1
if sayac == len(b):
	print(ekmek)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
b = [i % 2 == 0 for i in B]
u = 0
impossible = False
while True:
	stop = True
	for i in range(len(b)):
		if not b[i]:
			stop = False
			u += 1
			b[i] = True
			if i < N - 1:
				b[i + 1] = not b[i + 1]
				u += 1
			else:
				impossible = True
				stop = True
				break
	if stop:
		break
print('NO' if impossible else u)


import sys

def give_loaves(B):
	B[0] += 1
	B[1] += 1
	return B

def trim_odd(B):
	while len(B) > 0 and B[0] % 2 == 0:
		B.pop(0)
	while len(B) > 0 and B[-1] % 2 == 0:
		B.pop()
	return B

def fair_rations(B):
	loaves = 0
	while True:
		B = trim_odd(B)
		if len(B) == 0:
			return loaves
		elif len(B) == 1:
			return 'NO'
		else:
			B = give_loaves(B)
			loaves += 2
n = int(input())
B = [int(b) for b in input().split(' ')]
print(fair_rations(B))


import sys

def checkOdd(lst):
	for a in lst:
		if a % 2 == 1:
			return True
	return False
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
res = 0
if sum(B) % 2 == 1:
	print('NO')
else:
	while checkOdd(B):
		for i in range(len(B) - 1):
			if B[i] % 2 == 1:
				B[i] += 1
				B[i + 1] += 1
				res += 2
				break
	print(res)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
distributed = 0
oddPos = []
for i in range(len(B)):
	if B[i] % 2 == 1:
		oddPos.append(i)
if len(oddPos) % 2 == 1:
	print('NO')
	exit()
i = 0
while i < len(oddPos):
	distributed += 2 * (oddPos[i + 1] - oddPos[i])
	i += 2
print(distributed)


n = int(input())
a = list(map(int, input().split()))
total = sum(a)
ini_total = total
for i in range(n - 1):
	if a[i] % 2 != 0:
		total += 2
		a[i + 1] += 1
if total % 2 == 0:
	print(total - ini_total)
else:
	print('NO')


import sys

def solve(b):
	t = 0
	for i in range(len(b) - 1):
		if b[i] % 2 == 1:
			b[i] += 1
			b[i + 1] += 1
			t += 2
	print('NO' if b[-1] % 2 == 1 else t)
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
solve(B)


n = int(input().strip())
a = [int(s) for s in input().strip().split()]
if sum(a) % 2 > 0:
	print('NO')
else:
	counter = 0
	for i in range(n):
		if a[i] % 2 > 0:
			counter += 2
			a[i] += 1
			a[i + 1] += 1
	print(counter)


length = int(input())
line = list(map(int, input().strip().split(' ')))
count = 0
if list(map(lambda x: x % 2, line)).count(1) % 2 != 0:
	print('NO')
else:
	i = 0
	while i < length - 1:
		if line[i] % 2 != 0:
			count += 2
			line[i + 1] += 1
			i += 1
		else:
			i += 1
	print(count)


import sys
import bisect
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
bread = 0
odds = list(filter(lambda x: B[x] % 2, range(len(B))))
if len(odds) % 2:
	print('NO')
else:
	while odds:
		odd = odds.pop()
		if B[odd] % 2:
			bread += 2
			B[odd] += 1
			B[odd - 1] += 1
			if B[odd - 1] % 2:
				odds.append(odd - 1)
			else:
				odds.pop()
	print(bread)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
s = 0
while len(B) > 1:
	if B[-1] % 2 == 0:
		B.pop()
	else:
		B[-1] = B[-1] + 1
		B[-2] = B[-2] + 1
		s = s + 2
if B[0] % 2 == 0:
	print(s)
else:
	print('NO')


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
m = list(map(lambda i: i % 2, B))
count = 0
if sum(m) % 2 != 0:
	print('NO')
else:
	flag = 0
	begin = 0
	for i in range(len(B)):
		if m[i] == 1 and flag == 0:
			begin = i
			flag = 1
		elif m[i] == 1 and flag == 1:
			count += 2 * (i - begin)
			flag = 0
	print(count)


import sys
n = int(input().strip())
a = [int(B_temp) for B_temp in input().strip().split(' ')]
count = 0
d = 0
for i in range(0, len(a)):
	if i == 0 and a[i] % 2 == 1:
		a[i] += 1
		a[i + 1] += 1
		count += 2
	elif i == len(a) - 1 and a[i] % 2 == 1:
		d += 1
	elif a[i] % 2 == 1:
		a[i] += 1
		a[i + 1] += 1
		count += 2
if d == 0:
	print(count)
else:
	print('NO')


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
count = 0
i = 0
for i in range(len(B) - 1):
	if B[i] % 2 != 0:
		B[i] = B[i] + 1
		B[i + 1] = B[i + 1] + 1
		count += 2
for i in range(len(B)):
	if B[i] % 2 != 0:
		print('NO')
		break
	if i == len(B) - 1:
		print(count)


N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
count = 0
for i in range(len(B) - 1):
	if B[i] % 2 != 0:
		count += 2
		B[i + 1] += 1
if B[len(B) - 1] % 2 == 0:
	print(count)
else:
	print('NO')


import sys
N = int(input().strip())
q = [int(B_temp) for B_temp in input().strip().split(' ')]
loaves = 0
for (i, j) in enumerate(q):
	if i + 1 == len(q) and j % 2 != 0:
		loaves = -1
		break
	if j % 2 == 0:
		continue
	else:
		q[i] += 1
		q[i + 1] += 1
		loaves += 2
if loaves == -1:
	print('NO')
else:
	print(loaves)


import sys
n = int(input().strip())
b = [int(x) for x in input().strip().split(' ')]
out = 0
for i in range(n - 1):
	if b[i] % 2 == 1:
		(b[i], b[i + 1]) = (0, 1 ^ b[i + 1])
		out += 2
print(out if b[-1] % 2 == 0 else 'NO')


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
count = 0
dis = 0
for i in range(len(B)):
	if B[i] % 2 == 1:
		count += 1
		if count % 2 == 1:
			prev = i
		else:
			dis += 2 * (i - prev)
if count % 2 == 0:
	print(dis)
else:
	print('NO')


import sys
n = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
if n == 1:
	print(B[0] % 2)
else:
	loafs = 0
	for i in range(0, n - 1):
		if B[i] % 2 != 0:
			B[i] += 1
			B[i + 1] += 1
			loafs += 2
	if B[n - 1] % 2 != 0:
		print('NO')
	else:
		print(loafs)


N = int(input().strip())
B = list(map(int, input().strip().split(' ')))
ans = 0
for i in range(0, N - 1):
	if B[i] % 2 != 0:
		B[i] += 1
		B[i + 1] += 1
		ans += 2
if B[N - 1] % 2 == 0:
	print(ans)
else:
	print('NO')


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]

def isOdd(val):
	return val % 2

def isEven(arr):
	for v in arr:
		if v % 2 != 0:
			return False
	return True
amount = 0
for (i, b) in enumerate(B):
	if isOdd(b):
		if i - 1 >= 0 and isOdd(B[i - 1]):
			(B[i], B[i - 1]) = (B[i] + 1, B[i - 1] + 1)
			amount += 2
		elif i + 1 < N:
			(B[i], B[i + 1]) = (B[i] + 1, B[i + 1] + 1)
			amount += 2
if isEven(B):
	print(amount)
else:
	print('NO')


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
result = 0
for i in range(N - 1):
	if B[i] % 2:
		result += 2
		B[i + 1] += 1
print('NO' if B[-1] % 2 else result)


import sys
N = int(input().strip())
B = [int(B_temp) % 2 for B_temp in input().strip().split(' ')]
if B.count(1) % 2 == 1:
	print('NO')
else:
	numloaves = 0
	flag = False
	for i in range(N):
		if B[i] == 1:
			flag = not flag
		if flag:
			numloaves += 2
	print(numloaves)


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
answer = 0
for i in range(N - 1):
	if B[i] % 2 == 1:
		B[i] += 1
		B[i + 1] += 1
		answer += 2
print(answer if B[-1] % 2 == 0 else 'NO')


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
C = [i for i in range(N) if B[i] % 2 == 1]
if len(C) % 2 != 0:
	print('NO')
else:
	print(2 * sum((C[2 * i + 1] - C[2 * i] for i in range(int(len(C) / 2)))))


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
loafs = 0
for i in range(N):
	if i + 1 >= N and B[i] % 2 != 0:
		print('NO')
		break
	if i + 1 >= N and B[i] % 2 == 0:
		print(loafs)
		break
	if B[i] % 2 != 0:
		B[i] += 1
		B[i + 1] += 1
		loafs += 2


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
for i in range(len(B)):
	B[i] = B[i] % 2
odds = B.count(1)
if odds % 2 != 0:
	print('NO')
else:
	bread = 0
	j = 0
	for i in range(int(odds / 2)):
		ind1 = B.index(1, j)
		ind2 = B.index(1, ind1 + 1)
		j = ind2 + 1
		dist = ind2 - ind1
		bread += dist * 2
	print(str(bread))


import sys
N = int(input().strip())
B = [int(B_temp) for B_temp in input().strip().split(' ')]
if sum(B) % 2 == 1:
	print('NO')
else:
	answer = 0
	first = -1
	for i in range(len(B)):
		if B[i] % 2 == 1 and first == -1:
			first = i
		elif B[i] % 2 == 1:
			answer += 2 * (i - first)
			first = -1
	print(answer)