You are given a Young diagram. 

Given diagram is a histogram with n columns of lengths a_1, a_2, …, a_n (a_1 ≥ a_2 ≥ … ≥ a_n ≥ 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 × 2 or 2 × 1 rectangle.

Input

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

The next line of input contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 300 000, a_i ≥ 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> <image>
 
n = int(input())
arr = map(int,raw_input().split(" "))
i = n-1
last = 0
lasti = n-1
ans = 0
first = [0]*arr[0]
v1,v2 = 0,0
while i>=0:
	while i>= 0 and arr[i] == last:
		i-=1
	if i<0:
		break
	height = arr[i] - last
	ans += height*((i+1)/2)
	if (i+1)%2 == 1:
		for j in range(last,arr[i]):
			first[j] = 1
	last = arr[i]

for j in range(last,arr[0]):
	first[j] = 1

for i in range(arr[0]-1):
	if first[i] == 1 and first[i+1] == 1:
		ans += 1
		first[i+1] = 0
# print ans
for i in range(n):
	if i%2 == 0:
		v1 += (arr[i]+1)/2
		v2 += arr[i]/2
	else:
		v1 += arr[i]/2
		v2 += (arr[i]+1)/2
ans = min(v1,v2)
print ans
# print ans,i,first
