You are given a Young diagram. 

Given diagram is a histogram with $n$ columns of lengths $a_1, a_2, \ldots, a_n$ ($a_1 \geq a_2 \geq \ldots \geq a_n \geq 1$). [Image] Young diagram for $a=[3,2,2,2,1]$. 

Your goal is to find the largest number of non-overlapping dominos that you can draw inside of this histogram, a domino is a $1 \times 2$ or $2 \times 1$ rectangle.


-----Input-----

The first line of input contain one integer $n$ ($1 \leq n \leq 300\,000$): the number of columns in the given histogram.

The next line of input contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \leq a_i \leq 300\,000, a_i \geq a_{i+1}$): the lengths of columns.


-----Output-----

Output one integer: the largest number of non-overlapping dominos that you can draw inside of the given Young diagram.


-----Example-----
Input
5
3 2 2 2 1

Output
4



-----Note-----

Some of the possible solutions for the example:

[Image] $\square$

Source: codeforces | Difficulty: HARD
Tags: Dynamic programming

Mathematics

Greedy algorithms


Solutions:
n = int(input())
L = list(map(int, input().split()))
col = 'white'
w = 0
b = 0
for i in range(n):
	if col == 'white':
		w += (L[i] + 1) // 2
		b += L[i] // 2
		col = 'black'
	else:
		b += (L[i] + 1) // 2
		w += L[i] // 2
		col = 'white'
print(min(w, b))


import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
white = 0
black = 0
for (i, a) in enumerate(A):
	if a % 2 == 0:
		white += a // 2
		black += a // 2
	elif i % 2 == 0:
		black += a // 2
		white += a // 2 + 1
	else:
		white += a // 2
		black += a // 2 + 1
print(min(black, white))


import sys
import math
input = sys.stdin.readline
n = int(input())
arr = list(map(int, input().split()))
b = 0
w = 0
for i in range(n):
	if i % 2 == 0:
		b += math.ceil(arr[i] / 2)
		w += arr[i] // 2
	else:
		w += math.ceil(arr[i] / 2)
		b += arr[i] // 2
print(min(b, w))


from sys import stdin, stdout

def getmaxdonimo(n, aa):
	bcnt = 0
	wcnt = 0
	isblack = True
	for a in aa:
		bcnt += a // 2
		wcnt += a // 2
		if isblack:
			bcnt += a % 2
		else:
			wcnt += a % 2
		isblack = not isblack
	return min(bcnt, wcnt)
n = int(stdin.readline())
aa = list(map(int, stdin.readline().split()))
res = getmaxdonimo(n, aa)
stdout.write(str(res))


n = int(input())
a = list(map(int, input().split()))
ans1 = 0
ans2 = 0
for q in range(n):
	i = a[q]
	ans1 += i // 2
	ans2 += i // 2
	if i % 2 == 1:
		if q % 2 == 1:
			ans1 += 1
		else:
			ans2 += 1
print(min(ans1, ans2))


n = int(input())
a = [int(x) for x in input().split()]
(b, w) = (0, 0)
for i in range(n):
	if i % 2:
		w += (a[i] + 1) // 2
		b += a[i] // 2
	else:
		b += (a[i] + 1) // 2
		w += a[i] // 2
print(min(b, w))


n = int(input())
l = list(map(int, input().split()))
(a, b) = (0, 0)
for i in range(n):
	if l[i] % 2 == 1 and i % 2 == 0:
		b += l[i] // 2 + 1
		a += l[i] // 2
	elif l[i] % 2 == 1 and i % 2 == 1:
		b += l[i] // 2
		a += l[i] // 2 + 1
	else:
		b += l[i] // 2
		a += l[i] // 2
print(min(a, b))


n = int(input())
a = list(map(int, input().split()))
counts = [0] * 2
for i in range(n):
	counts[i & 1] += a[i] // 2
	counts[i & 1 ^ 1] += (a[i] + 1) // 2
print(min(counts))


(n, x, y) = (int(input()), 0, 0)
domino = list(map(int, input().strip().split()))
for h in domino:
	(x, y) = (y + h // 2, x + (h + 1) // 2)
print(min(x, y))


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=10 ** 6, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(10)]
pp = [0] * 10

def SieveOfEratosthenes(n=10):
	p = 2
	c = 0
	while p * p <= n:
		if prime[p] == True:
			c += 1
			for i in range(p, n + 1, p):
				pp[i] += 1
				prime[i] = False
		p += 1

def binarySearch(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = 0
	while left <= right:
		mid = (right + left) // 2
		if arr[mid][0] > key:
			right = mid - 1
		else:
			res = mid
			left = mid + 1
	return res
n = int(input())
a = list(map(int, input().split()))
ch = 1
(black, white) = (0, 0)
for num in a:
	if ch:
		ch = 0
		black += (num + 1) // 2
		white += num // 2
	else:
		ch = 1
		white += (num + 1) // 2
		black += num // 2
print(min(black, white))


n = int(input())
a = input().split(' ')
for i in range(n):
	a[i] = int(a[i])
w = a[0] // 2
b = a[0] - w
c = 1

def no(x):
	if x == 1:
		return 0
	return 1
for i in range(1, len(a)):
	if a[i - 1] % 2 == 0:
		if a[i] % 2 == 0:
			w += a[i] // 2
			b += a[i] // 2
			c = no(c)
		elif c == 1:
			w += a[i] // 2
			b += a[i] - a[i] // 2
		else:
			b += a[i] // 2
			w += a[i] - a[i] // 2
	elif a[i] % 2 == 0:
		w += a[i] // 2
		b += a[i] // 2
	else:
		if c == 1:
			b += a[i] // 2
			w += a[i] - a[i] // 2
		else:
			w += a[i] // 2
			b += a[i] - a[i] // 2
		c = no(c)
print(min(b, w))


(n, x, y) = (int(input()), 0, 0)
l = list(map(int, input().split()))
for a in l:
	(x, y) = (y + a // 2, x + (a + 1) // 2)
print(min(x, y))


from sys import stdin
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
sum = sum(a)
cnt = 0
for i in range(n):
	if i % 2 == 0:
		cnt += a[i] // 2
	else:
		cnt += (a[i] + 1) // 2
print(min(cnt, sum - cnt))


import math
number_of_columns = int(input())
number_of_cells = 0
figure = input().split()
black_count = 0
white_count = 0
for col_index in range(number_of_columns):
	number_of_cells = int(figure[col_index])
	white_count_col = 0
	black_count_col = 0
	if col_index % 2 == 0:
		white_count_col += math.trunc(number_of_cells / 2)
		if number_of_cells % 2 == 1:
			white_count_col += 1
		black_count_col = number_of_cells - white_count_col
	else:
		black_count_col += math.trunc(number_of_cells / 2)
		if number_of_cells % 2 == 1:
			black_count_col += 1
		white_count_col = number_of_cells - black_count_col
	white_count += white_count_col
	black_count += black_count_col
print(min(white_count, black_count))


n = int(input())
a = list(map(int, input().split()))
sol = 0
w = 0
b = 0
for (i, ai) in enumerate(a):
	w += ai // 2
	b += ai // 2
	if ai % 2:
		if i % 2:
			w += 1
		else:
			b += 1
sol = min(w, b)
print(sol)


n = int(input())
a = list(map(int, input().split()))
p = 0
q = 0
for i in range(n):
	if i % 2:
		p += a[i] // 2
		q += a[i] - a[i] // 2
	if i % 2 == 0:
		q += a[i] // 2
		p += a[i] - a[i] // 2
print(min(p, q))


from math import *
from collections import *
import sys
sys.setrecursionlimit(10 ** 9)
n = int(input())
a = list(map(int, input().split()))
ctw = ctb = 0
for i in range(n):
	if i % 2 == 0:
		ctw += a[i] // 2
		ctb += a[i] - a[i] // 2
	else:
		ctb += a[i] // 2
		ctw += a[i] - a[i] // 2
print(min(ctb, ctw))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')
from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	n = N()
	arr = RLL()
	res = [0, 0]
	for i in range(n):
		res[i % 2] += arr[i] // 2
		res[(i + 1) % 2] += (arr[i] + 1) // 2
	print(min(res))
main()


import math
N = int(input())
arr = [int(x) for x in input().split()]
tot = 0
hor = 0
for i in range(N):
	if arr[i] >= hor or hor % 2 == arr[i] % 2:
		tot += int(math.ceil(min(hor, arr[i]) / 2))
	else:
		tot += int(math.ceil((min(hor, arr[i]) - 1) / 2))
	if arr[i] >= hor:
		tot += (arr[i] - hor) // 2
		if (arr[i] - hor) % 2 == 0:
			hor = max(hor - 1, 0)
		else:
			hor += 1
	else:
		hor -= 1
		hor2 = arr[i]
		if hor2 % 2 != hor % 2:
			hor2 -= 1
		hor = max(hor2, 0)
print(tot)


import sys
import math
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(0, n, 1):
	ans += (a[i] + i % 2) // 2
print(min(ans, sum(a) - ans))


n = int(input())
domino = list(map(int, input().strip().split()))
dye = [0] * 2
for i in range(len(domino)):
	dye[i % 2] += domino[i] // 2
	dye[(i + 1) % 2] += (domino[i] + 1) // 2
print(min(dye))


n = int(input())
a = list(map(int, input().split()))
(black, white) = [0, 0]
for i in range(n):
	if i % 2 == 0:
		black += a[i] // 2
		white += a[i] - a[i] // 2
	else:
		white += a[i] // 2
		black += a[i] - a[i] // 2
print(min(black, white))


n = int(input())
arr = list(map(int, input().split()))
ans_1 = 0
ans_2 = 0
for i in range(n):
	if i % 2 == 1:
		ans_1 += int(arr[i] / 2) + arr[i] % 2
		ans_2 += int(arr[i] / 2)
	else:
		ans_1 += int(arr[i] / 2)
		ans_2 += int(arr[i] / 2) + arr[i] % 2
print(min(ans_1, ans_2))


n = int(input())
a = list(map(int, input().split()))
even = odd = 0
for i in range(n):
	even += a[i] // 2
	odd += a[i] // 2
	if a[i] % 2:
		if i % 2:
			odd += 1
		else:
			even += 1
print(min(odd, even))


import sys
readline = sys.stdin.readline
N = int(readline())
A = list(map(int, readline().split()))
BW = [0, 0]
for i in range(N):
	a = A[i]
	BW[i % 2] += a // 2
	BW[(i + 1) % 2] += -(-a // 2)
print(min(BW))


n = int(input())
arr = [int(x) for x in input().split()]
ans = 0
for i in range(len(arr)):
	ans += arr[i] // 2
	arr[i] %= 2
for i in range(2, len(arr)):
	arr[i % 2] += arr[i]
if n > 1:
	ans += min(arr[0], arr[1])
print(ans)


import sys
input = sys.stdin.readline
n = int(input())
a = [int(item) for item in input().split()] + [0]
black = 0
white = 0
for (i, item) in enumerate(a):
	if item % 2 == 0:
		black += item // 2
		white += item // 2
	elif i % 2 == 0:
		black += (item + 1) // 2
		white += item // 2
	else:
		white += (item + 1) // 2
		black += item // 2
print(min(black, white))


from collections import deque, Counter
import array
from itertools import combinations, permutations
from math import sqrt

def read_int():
	return int(input().strip())

def read_int_array():
	return [int(i) for i in input().strip().split(' ')]
n = read_int()
cols = read_int_array()
i = 0
blacks = 0
while i < n:
	if i % 2 == 0:
		blacks += cols[i] // 2
	else:
		blacks += cols[i] - cols[i] // 2
	i += 1
print(min(blacks, sum(cols) - blacks))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def chck(s, k):
	for ii in range(k):
		curr = s[ii]
		for i in range(ii + k, len(s), k):
			if s[i] == curr:
				continue
			return False
	return True

def solve(case):
	n = int(inp())
	a = lis()
	cnt1 = 0
	cnt2 = 0
	for i in range(0, n, 2):
		cnt1 += a[i] // 2
		cnt2 -= a[i] // 2
		cnt2 += a[i]
	for i in range(1, n, 2):
		cnt1 -= a[i] // 2
		cnt2 += a[i] // 2
		cnt1 += a[i]
	print(min(cnt1, cnt2))
testcase(1)


a = int(input())
A = list(map(int, input().split()))
w = 0
b = 0
for i in range(a):
	A[i] += i % 2
	b += A[i] // 2
	w += A[i] - A[i] // 2 - i % 2
print(min(b, w))


n = int(input())
a = list(map(int, input().split()))
dp = [0 for _ in range(2)]
pre = -1
for i in range(n):
	if i % 2 == 0:
		dp[0] += a[i] // 2
		dp[1] += a[i] - a[i] // 2
	else:
		dp[0] += a[i] - a[i] // 2
		dp[1] += a[i] // 2
print(min(dp[0], dp[1]))


n = int(input())
a = list(map(int, input().split()))
ans = 0
k = [0, 0]
for _ in range(n):
	ans += int(a[_] / 2)
	if a[_] % 2 == 1:
		k[_ % 2] += 1
print(int(ans + min(k)))


n = int(input())
vals = list(map(int, input().split(' ')))
(black, white) = (0, 0)
even = False
for v in vals:
	vdiv2 = v // 2
	black += vdiv2
	white += vdiv2
	if v & 1:
		if even:
			black += 1
		else:
			white += 1
	even = not even
print(min(black, white))


input()
a = [*map(int, input().split())]
b = sum((e // 2 for e in a[::2])) + sum(((e + 1) // 2 for e in a[1::2]))
print(min(sum(a) - b, b))


from sys import stdin
import collections
import copy
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
ans = 0
left = []
for i in range(len(a)):
	ans += a[i] // 2
	if a[i] % 2:
		if not len(left):
			left.append(i)
		elif (i - left[-1]) % 2:
			left.pop()
			ans += 1
		else:
			left.append(i)
print(ans)


import sys
from collections import Counter
reader = (map(int, line.split()) for line in sys.stdin)
input = reader.__next__
(n,) = input()
a = list(input())

def nDominos(a, n):
	w = 0
	b = 0
	for (i, el) in enumerate(a):
		w += el // 2
		b += el // 2
		if el % 2 == 1:
			if i % 2 == 1:
				w += 1
			else:
				b += 1
	return min(w, b)
ans = nDominos(a, n)
print(ans)


n = int(input())
l = list(map(int, input().split()))
cz = 0
bi = 0
for i in range(n):
	if i % 2 == 0:
		cz += l[i] // 2
		bi += l[i] - l[i] // 2
	else:
		bi += l[i] // 2
		cz += l[i] - l[i] // 2
print(min(bi, cz))


import sys
import math
from collections import defaultdict, Counter
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for i in range(1):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = [0, 0]
	for j in range(n):
		if j % 2 == 0:
			cnt[0] += a[j] // 2
			cnt[1] += (a[j] + 1) // 2
		else:
			cnt[1] += a[j] // 2
			cnt[0] += (a[j] + 1) // 2
	print(min(cnt))


import sys
import collections
from collections import Counter
import itertools
import math
import timeit

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

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

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
n = ii()
d = li()
r = [0, 0]
for i in range(n):
	t = d[i] // 2
	r[0] += t
	r[1] += t
	if d[i] % 2:
		r[i % 2] += 1
print(min(r))


from sys import stdin, stdout
n = int(stdin.readline().strip())
alist = list(map(int, stdin.readline().split()))
k = max(alist)
(total, odd, even) = (0, 0, 0)
for (i, a) in enumerate(alist):
	total += a // 2
	if a % 2:
		if i % 2:
			odd += 1
		else:
			even += 1
total += min(odd, even)
print(total)


import os, sys, math
import collections
if os.path.exists('testing'):
	name = os.path.basename(__file__)
	if name.endswith('.py'):
		name = name[:-3]
	src = open(name + '.txt', encoding='utf8')
	input = src.readline

def solve():
	counts = []
	for o in (0, 1):
		cc = 0
		for x in data:
			cc += (x + o) // 2
			o = 1 - o
		counts.append(cc)
	return min(counts)

def integers():
	return map(int, input().strip().split())

def array_of_integers(q):
	return [tuple(map(int, input().strip().split())) for _ in range(q)]
n = integers()
data = list(integers())
res = solve()
print(res)


n = int(input())
a = list(map(int, input().split()))
ans = 0
black = 0
white = 0
for i in range(n):
	if i % 2 == 0:
		black += a[i] // 2
		white += a[i] - a[i] // 2
	elif i % 2 == 1:
		white += a[i] // 2
		black += a[i] - a[i] // 2
print(min(white, black))


n = int(input())
it = list(map(int, input().split()))
a = 0
b = 0
for i in range(n):
	if i % 2 == 0:
		a += it[i] // 2
		b += it[i] // 2
		a += it[i] % 2
	else:
		b += it[i] // 2
		a += it[i] // 2
		b += it[i] % 2
print(min(a, b))


input()
(a, b) = (0, 0)
l = map(int, input().split(' '))
for v in l:
	a += v // 2
	b += v - v // 2
	(a, b) = (b, a)
print(min(a, b))


n = int(input())
a = list(map(int, input().split()))
b = w = 0
for i in a:
	b += (i + 1) // 2
	w += i // 2
	(b, w) = (w, b)
print(min(b, w))


import sys
import math
input = sys.stdin.readline
a = int(input())
m = list(map(int, input().split()))
white = 0
black = 0
for i in range(a):
	if i % 2 == 0:
		white += math.ceil(m[i] / 2)
		black += math.floor(m[i] / 2)
	if i % 2 == 1:
		black += math.ceil(m[i] / 2)
		white += math.floor(m[i] / 2)
print(min(black, white))


n = int(input())
a = [int(i) for i in input().split()]
m = [0, 0]
for i in range(n):
	m[0] += a[i] // 2
	m[1] += a[i] // 2
	if a[i] % 2 != 0:
		m[i % 2] += 1
print(int(min(m[0], m[1])))


n = int(input())
a = list(map(int, input().split()))
black = 0
white = 0
j = 0
while j < n:
	black += (a[j] + 1) // 2
	white += a[j] // 2
	(black, white) = (white, black)
	j += 1
print(min(black, white))


N = int(input())
A = list(map(int, input().split()))
prev_odd = []
ans = 0
for i in range(N):
	if A[i] % 2 == 0:
		ans += A[i] // 2
	else:
		if prev_odd:
			if (i - prev_odd[-1]) % 2 == 1:
				ans += 1
				prev_odd.pop()
			else:
				prev_odd.append(i)
		else:
			prev_odd.append(i)
		ans += A[i] // 2
print(ans)


n = int(input())
A = list(map(int, input().split()))
A.append(0)
White = 0
Black = 0
for i in range(n):
	A[i] += i % 2
	Black += A[i] // 2
	White += A[i] - A[i] // 2 - i % 2
print(min(Black, White))


input()
a = [*map(int, input().split())]
b = sum(((a[i] + i % 2) // 2 for i in range(len(a))))
print(min(sum(a) - b, b))


n = int(input())
mas = list(map(int, input().split()))
kol1 = 0
kol2 = 0
now = 0
for i in range(n):
	if now == 0:
		if mas[i] % 2 == 0:
			kol1 += mas[i] // 2
			kol2 += mas[i] // 2
		else:
			kol1 += mas[i] // 2 + 1
			kol2 += mas[i] // 2
		now = 1
	else:
		if mas[i] % 2 == 0:
			kol1 += mas[i] // 2
			kol2 += mas[i] // 2
		else:
			kol1 += mas[i] // 2
			kol2 += mas[i] // 2 + 1
		now = 0
print(min(kol1, kol2))


N = int(input())
A = list(map(int, input().split()))
num_white = 0
num_black = 0
for i in range(N):
	if i % 2 == 0:
		num_white += (A[i] + 1) // 2
		num_black += A[i] - (A[i] + 1) // 2
	else:
		num_black += (A[i] + 1) // 2
		num_white += A[i] - (A[i] + 1) // 2
print(min(num_white, num_black))


def f():
	n = int(input())
	a = [int(s) for s in input().split()]
	r = [a[i] % 2 for i in range(n)]
	i = 0
	count = [0, 0]
	for i in range(n):
		if r[i]:
			count[i % 2] += 1
	blank = abs(count[0] - count[1])
	sum = -blank
	for i in range(n):
		sum += a[i]
	print(sum // 2)
f()


n = int(input())
A = [int(i) for i in input().split()]
black = white = 0
for i in range(n):
	if i % 2:
		black += (A[i] + 1) // 2
		white += A[i] // 2
	else:
		black += A[i] // 2
		white += (A[i] + 1) // 2
print(min(black, white))


n = int(input())
h = list(map(int, input().split()))
(check, ans, skip) = ([0] * 300001, 0, -1)
for i in range(n):
	ans += h[i] // 2
	if h[i] % 2 == 1:
		check[i - 1] = min(check[i - 1], h[i] - (check[i - 1] % 2 + 1) % 2)
		if i > 0 and check[i - 1] % 2 == 0:
			check[i] = check[i - 1] + 1
		elif i > 0 and check[i - 1] % 2 == 1:
			check[i] = check[i - 1] - 1
			ans += 1
		if i == 0:
			check[0] = 1
	else:
		if check[i - 1] == 0:
			continue
		check[i - 1] = min(check[i - 1], h[i] - check[i - 1] % 2)
		if i > 0 and check[i - 1] % 2 == 1:
			check[i] = check[i - 1] + 1
		elif i > 0 and check[i - 1] % 2 == 0:
			check[i] = check[i - 1] - 1
print(ans)


x = int(input())
y = input()
y = y.split()
W = 0
B = 0
for i in range(x):
	if i % 2 == 0:
		if int(y[i]) % 2 == 0:
			W = W + int(y[i]) / 2
			B = B + int(y[i]) / 2
		else:
			W = W + (int(y[i]) + 1) / 2
			B = B + (int(y[i]) - 1) / 2
	elif int(y[i]) % 2 == 0:
		W = W + int(y[i]) / 2
		B = B + int(y[i]) / 2
	else:
		W = W + (int(y[i]) - 1) / 2
		B = B + (int(y[i]) + 1) / 2
print(int(min(B, W)))


n = int(input())
a = list(map(int, input().split()))
ans = 0
for q in range(n):
	if q % 2 == 0:
		ans += (a[q] + 1) // 2
	else:
		ans += a[q] // 2
print(min(ans, sum(a) - ans))


import math
import sys
pi = 3.1415
t = 1
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	(wh, bl) = (0, 0)
	for i in range(len(a)):
		(wh, bl) = (wh + a[i] // 2, bl + a[i] // 2)
		if a[i] % 2:
			if i % 2:
				wh += 1
			else:
				bl += 1
	print(min(wh, bl))


(n, m) = (0, 0)
l = int(input())
a = input().split()
for i in range(l):
	a[i] = int(a[i])
for i in range(l):
	m += a[i]
	if i % 2 == 0:
		n += a[i] // 2
	else:
		n += a[i] - a[i] // 2
m -= n
print(min(n, m))


import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
B = 0
C = 0
D = 0
E = 0
for i in range(n):
	a = A[i]
	if i % 2 == 0:
		B += a // 2
		C += a - a // 2
		D += a - a // 2
		E += a // 2
	else:
		B += a - a // 2
		C += a // 2
		D += a // 2
		E += a - a // 2
print(max(min(B, C), min(D, E)))


(n, a, b) = (int(input()), 0, 0)
lst = map(int, input().split())
for thing in lst:
	(a, b) = (b + (thing >> 1), a + (thing + 1 >> 1))
print(min(a, b))


import re

def slip():
	return re.sub('00|11', '', mid)
n = int(input())
nums = list(map(int, input().split()))
mid = ''
for i in nums:
	if i % 2:
		mid += '1'
	else:
		mid += '0'
l = 0
while l != len(mid):
	l = len(mid)
	mid = slip()
print((sum(nums) - mid.count('1')) // 2)


def find(A):
	on = 1
	ans = 0
	for x in A:
		if on == 1:
			ans += x // 2 + x % 2
			on = 0
		else:
			ans += x // 2
			on = 1
	return min(ans, sum(A) - ans)
n = int(input())
A = list(map(int, input().strip().split()))
print(find(A))


n = int(input())
a = map(int, input().split())
x = 0
y = 0
for i in a:
	x += i // 2
	y += (i + 1) // 2
	(x, y) = (y, x)
print(min(x, y))


n = int(input())
A = list(map(int, input().split()))
blacks = 0
whites = 0
parity = 0
for a in A:
	if parity:
		whites += a // 2
		blacks += a - a // 2
	else:
		whites += a - a // 2
		blacks += a // 2
	parity ^= 1
print(min(blacks, whites))


n = int(input())
a = list(map(int, input().split(' ')))
(A, B) = (0, 0)
for (i, v) in enumerate(a):
	g = (v + 1) // 2
	l = v - g
	if i % 2:
		(g, l) = (l, g)
	(A, B) = (A + g, B + l)
print(min(A, B))


from math import ceil, floor
n = int(input())
a = list(map(int, input().split()))
b = 0
for i in range(n):
	if i % 2 == 0:
		b += ceil(a[i] / 2)
	else:
		b += floor(a[i] / 2)
print(min(sum(a) - b, b))


def main():
	n = int(input())
	a = readIntArr()
	whites = 0
	blacks = 0
	for (i, x) in enumerate(a):
		y = x // 2
		z = x - y
		if i % 2 == 0:
			whites += y
			blacks += z
		else:
			whites += z
			blacks += y
	print(min(whites, blacks))
	return
import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

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

def makeArr(defaultVal, dimensionArr):
	dv = defaultVal
	da = dimensionArr
	if len(da) == 1:
		return [dv for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(x, y):
	print('? {} {}'.format(x, y))
	sys.stdout.flush()
	return int(input())

def queryInteractive2(arr):
	print('? ' + ' '.join([str(x) for x in arr]))
	sys.stdout.flush()
	return [int(x) for x in input().split()]

def answerInteractive(ans):
	print('! {}'.format(ans))
	sys.stdout.flush()
inf = float('inf')
MOD = 10 ** 9 + 7
for _abc in range(1):
	main()


n = int(input())
a = list(map(int, input().split()))
nech = 0
ch = 0
for i in range(n):
	if i % 2 == 0:
		nech += a[i] % 2 + a[i] // 2
		ch += a[i] // 2
	else:
		ch += a[i] % 2 + a[i] // 2
		nech += a[i] // 2
print(min(ch, nech))


n = int(input())
ls = list(map(int, input().split()))
(l, r) = (0, 0)
for x in range(n):
	c = ls[x]
	a = c // 2 if x % 2 == 0 else 1 + (c - 1) // 2
	r += a
	l += c - a
print(min(l, r))


from sys import stdin, stdout

def scal(typ=int):
	return typ(stdin.readline())

def vec(typ=int):
	if isinstance(typ, list):
		inp = stdin.readline().split()
		return [typ[i](inp[i]) for i in range(len(inp))]
	else:
		return list(map(typ, stdin.readline().split()))
n = scal()
A = vec()
(i, b, w) = (0, 0, 0)
for a in A:
	if i:
		w += a - a // 2
		b += a // 2
	else:
		w += a // 2
		b += a - a // 2
	i = 1 - i
print(min(b, w))


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
	if i % 2 == 0:
		ans += (l[i] + 1) // 2
	else:
		ans += l[i] // 2
print(min(ans, sum(l) - ans))


n = int(input())
(b, w) = (0, 0)
cols = [int(x) for x in input().split()]
for c in range(n):
	if cols[c] % 2 == 1:
		b += c % 2
		w += (c + 1) % 2
print((sum(cols) - abs(b - w)) // 2)


d = int(input())
l = list(map(int, input().split()))
res = 0
cr = 0
w = l[0] // 2
b = l[0] - w
for i in range(1, d):
	if (i + 1) % 2 != 0:
		w = w + l[i] // 2
		b = b + l[i] - l[i] // 2
	else:
		b = b + l[i] // 2
		w = w + l[i] - l[i] // 2
print(min(b, w))


import sys
n = int(sys.stdin.readline().strip())
a = list(map(int, sys.stdin.readline().strip().split()))
d = 0
s = 0
for i in range(0, n):
	s = s + a[i]
	if i % 2 == 0:
		d = d + a[i] % 2
	else:
		d = d - a[i] % 2
print((s - abs(d)) // 2)


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


n = int(input())
a = map(int, input().split())
col = [0, 0]
for (index, item) in enumerate(a):
	col[index & 1] = col[index & 1] + (item + 1) // 2
	col[1 - (index & 1)] = col[1 - (index & 1)] + item // 2
print(min(col))


n = int(input())
array = list(map(int, input().split()))
(c1, c2) = (0, 0)
for i in range(n):
	a = array[i]
	if a % 2 == 0:
		c1 += a // 2
		c2 += a // 2
	else:
		c1 += a // 2
		c2 += a // 2
		if i % 2 == 0:
			c1 += 1
		else:
			c2 += 1
print(min(c1, c2))


n = int(input())
arr = list(map(int, input().split()))
cnt = 0
for i in range(n):
	cnt += (arr[i] + 1 - i % 2) // 2
print(min(cnt, sum(arr) - cnt))


n = int(input())
a = list(map(int, input().split()))
k = 1
white = 0
black = 0
for i in a:
	black += i // 2 + k * (i % 2)
	white += i // 2 + (1 - k) * (i % 2)
	k = 1 - k
print(min(black, white))


n = int(input())
arr = list(map(int, input().split()))
hrz = 0
cnt = 0
for i in range(n):
	nblock = arr[i] - hrz
	cnt += nblock // 2
	cnt += hrz // 2 + hrz % 2
	if i == n - 1:
		continue
	if nblock % 2 == 1:
		hrz += 1
	elif hrz > 0:
		hrz -= 1
	if hrz > arr[i + 1]:
		if hrz % 2 == arr[i + 1] % 2:
			hrz = arr[i + 1]
		else:
			hrz = arr[i + 1] - 1
print(cnt)


(a1, a2) = (0, 0)
n = int(input())
ar = list(map(int, input().split()))
for e in ar:
	(a1, a2) = (a2, a1)
	a1 += e // 2
	a2 += e - e // 2
print(min(a1, a2))


from sys import stdin, gettrace
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():
	n = int(input())
	aa = [int(a) for a in input().split()]
	rem = 0
	black = 0
	white = 0
	for (i, a) in enumerate(aa):
		black += a // 2
		white += a // 2
		if a % 2 == 1:
			if i % 2 == 0:
				black += 1
			else:
				white += 1
	print(min(black, white))
main()


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
from decimal import Decimal
INF = float('inf')
mod = int(1000000000.0) + 7
n = int(data())
A = mdata()
(a, b) = (0, 0)
for i in A:
	a += i // 2
	b += i - i // 2
	(a, b) = (b, a)
out(min(a, b))


n = int(input())
l = list(map(int, input().split()))
(b, w) = (0, 0)
black_prev = False
for i in l:
	(j, k) = divmod(i, 2)
	b += j
	w += j
	if black_prev:
		w += k
	else:
		b += k
	black_prev = not black_prev
print(min(b, w))


n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
	ans += (a[i] + i % 2) // 2
print(min(ans, sum(a) - ans))


import sys
n = int(input())
a = list(map(int, input().split(' ')))
parity = 0
(even, odd) = (0, 0)
for x in a:
	even += x // 2
	odd += x // 2
	if x % 2 == 1:
		if parity == 0:
			even += 1
		else:
			odd += 1
	parity = 1 - parity
print(min(even, odd))


n = int(input())
l = list(map(int, input().split()))
r = 0
b = 0
for i in range(len(l)):
	if l[i] % 2 == 1:
		if i % 2 == 1:
			r += int(l[i] / 2) + 1
			b += int(l[i] / 2)
		else:
			r += int(l[i] / 2)
			b += int(l[i] / 2) + 1
	else:
		r += int(l[i] / 2)
		b += int(l[i] / 2)
print(min(r, b))


n = int(input())
a = list(map(int, input().split()))
b = w = 0
key = True
for j in range(len(a)):
	if key:
		if a[j] % 2 == 0:
			b += a[j] // 2
			w += a[j] // 2
		else:
			b += a[j] // 2 + 1
			w += a[j] // 2
		key = False
	else:
		if a[j] % 2 == 0:
			w += a[j] // 2
			b += a[j] // 2
		else:
			w += a[j] // 2 + 1
			b += a[j] // 2
		key = True
print(min(w, b))


n = int(input())
a = list(map(int, input().split()))
ans = [0, 0]
color = 0
for x in a:
	ans[color] += x // 2
	color ^= 1
	ans[color] += x - x // 2
print(min(ans))


INF = 10 ** 10

def main():
	n = get_int()
	li = get_list()
	stk = []
	for i in li:
		if i % 2 == 0 and len(stk) > 0:
			stk[-1] += 1
		elif i % 2 != 0:
			if len(stk) == 0:
				stk.append(0)
			elif stk[-1] % 2 == 0:
				stk.pop()
			else:
				stk.append(0)
	print((sum(li) - len(stk)) // 2)
import sys
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda : int(input())
get_list = lambda : list(map(int, input().split()))
main()
print(*out, sep='\n')


N = int(input())
cols = list(map(int, input().split()))
b = 0
w = 0
for (i, col) in enumerate(cols):
	if i % 2 == 0:
		b += col // 2
		w += col - col // 2
	else:
		b += col - col // 2
		w += col // 2
print(min(b, w))


import sys
input = sys.stdin.readline
lastodd = []
n = int(input())
a = [int(i) for i in input().split()]
ans = 0
for i in range(n):
	if not a[i] & 1:
		ans += a[i] // 2
	else:
		if lastodd:
			if i - lastodd[-1] & 1:
				ans += 1
				lastodd.pop()
			else:
				lastodd.append(i)
		else:
			lastodd.append(i)
		ans += a[i] // 2
print(ans)


n = int(input())
l = [int(i) for i in input().split(' ')]
tot = sum((i // 2 for i in l))
stack = []
for i in range(n):
	l[i] &= 1
	if not stack or stack[-1] != l[i]:
		stack.append(l[i])
	else:
		tot += stack.pop()
print(tot)


n = input()
L = map(int, input().split())
base_is_white = True
white = 0
black = 0
for x in L:
	if base_is_white:
		white += x // 2 + x % 2
		black += x // 2
		base_is_white = False
	else:
		white += x // 2
		black += x // 2 + x % 2
		base_is_white = True
print(min(white, black))


n = int(input())
arr = list(map(int, input().split()))
bl = 0
wh = 0
for i in range(n):
	if i % 2 == 0:
		wh = wh + arr[i] // 2
		bl = bl + arr[i] - arr[i] // 2
	else:
		bl = bl + arr[i] // 2
		wh = wh + arr[i] - arr[i] // 2
print(min(bl, wh))


n = int(input())
data = list(map(int, input().split()))
(b, w) = (0, 0)
for i in range(n):
	n_even = int(data[i] / 2)
	n_odd = data[i] - n_even
	if i % 2 == 0:
		b += n_even
		w += n_odd
	else:
		b += n_odd
		w += n_even
print(min(b, w))


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
from math import inf, log2
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class LazySegmentTree:

	def __init__(self, array, func=max):
		self.n = len(array)
		self.size = 2 ** (int(log2(self.n - 1)) + 1) if self.n != 1 else 1
		self.func = func
		self.default = 0 if self.func != min else inf
		self.data = [self.default] * (2 * self.size)
		self.lazy = [0] * (2 * self.size)
		self.process(array)

	def process(self, array):
		self.data[self.size:self.size + self.n] = array
		for i in range(self.size - 1, -1, -1):
			self.data[i] = self.func(self.data[2 * i], self.data[2 * i + 1])

	def push(self, index):
		self.lazy[2 * index] += self.lazy[index]
		self.lazy[2 * index + 1] += self.lazy[index]
		self.data[2 * index] += self.lazy[index]
		self.data[2 * index + 1] += self.lazy[index]
		self.lazy[index] = 0

	def build(self, index):
		index >>= 1
		while index:
			self.data[index] = self.func(self.data[2 * index], self.data[2 * index + 1]) + self.lazy[index]
			index >>= 1

	def query(self, alpha, omega):
		res = self.default
		alpha += self.size
		omega += self.size + 1
		for i in range(len(bin(alpha)[2:]) - 1, 0, -1):
			self.push(alpha >> i)
		for i in range(len(bin(omega - 1)[2:]) - 1, 0, -1):
			self.push(omega - 1 >> i)
		while alpha < omega:
			if alpha & 1:
				res = self.func(res, self.data[alpha])
				alpha += 1
			if omega & 1:
				omega -= 1
				res = self.func(res, self.data[omega])
			alpha >>= 1
			omega >>= 1
		return res

	def update(self, alpha, omega, value):
		alpha += self.size
		omega += self.size + 1
		(l, r) = (alpha, omega)
		while alpha < omega:
			if alpha & 1:
				self.data[alpha] += value
				self.lazy[alpha] += value
				alpha += 1
			if omega & 1:
				omega -= 1
				self.data[omega] += value
				self.lazy[omega] += value
			alpha >>= 1
			omega >>= 1
		self.build(l)
		self.build(r - 1)
n = int(input())
l = list(map(int, input().split()))
b = 0
w = 0
for i in range(n):
	if i % 2 == 0:
		b += int(math.ceil(l[i] / 2))
		w += l[i] // 2
	else:
		w += int(math.ceil(l[i] / 2))
		b += l[i] // 2
print(min(b, w))


n = int(input())
hist = [int(i) for i in input().split()]
total = sum(hist)
white = 0
black = 0
for i in range(n):
	if i % 2 == 0:
		white += hist[i] // 2
	else:
		white += (hist[i] + 1) // 2
black = total - white
print(min(white, black))