Problem:
 Score : 400 points    Problem Statement Snuke has a large collection of cards. Each card has an integer between 1 and N , inclusive, written on it.
He has A_i cards with an integer i .  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1 .  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.      Constraints  1 ≦ N ≦ 10^5  0 ≦ A_i ≦ 10^9 (1 ≦ i ≦ N)  All input values are integers.         Input The input is given from Standard Input in the following format:  N  A_1 : A_N       Output Print the maximum number of pairs that Snuke can create.        Sample Input 1 4
4
0
3
2      Sample Output 1 4  For example, Snuke can create the following four pairs: (1,1),(1,1),(3,4),(3,4) .       Sample Input 2 8
2
0
1
6
0
8
2
1      Sample Output 2 9

Solution (Python):
n = int(input())
a = []
temp = 0
temp_num = -1
ans = 0
t = []
for i in range(1, n+1):    
    k = int(input())
    if ((i - temp_num) <= 1) & (temp > 0):
        min_k = min(k, temp)
        ans += min_k
        temp = k - min_k
        ans += (temp // 2)
        temp -= (temp // 2) * 2
        temp_num = i
    else:
        temp = k
        temp_num = i
        ans += (temp // 2)
        temp -= (temp // 2) * 2
print(ans)

Solution (Python):
n = int(input())
a = []
for i in range(n):
    a1 = int(input())
    a.append(a1)
count = 0
kuri = 0
for i in range(n):
    if a[i] % 2 == 0:
        count += int(a[i]/2)
        if a[i] == 0:
            kuri = 0
    else:
        if kuri == 1:
            count += a[i]//2 + 1
            kuri = 0
        else:
            count += a[i]//2
            kuri = 1
print(count)

Solution (Python):
n = int(input())
a = [int(input()) for i in range(n)]

ans = a[0] // 2
for i in range(1,n):
  tmp = a[i-1] % 2 + a[i]
  ans += tmp // 2
  if tmp // 2:
    a[i] = tmp % 2
print(ans)

Solution (Python):
n,*A = map(int,open(0).read().split())
A += [0]
psum = ans = 0
for a in A:
	if a:
		psum += a
	else:
		ans += psum//2
		psum = 0
print(ans)

Solution (Python):
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def sol():
    N = int(input())
    A = [int(input()) for _ in range(N)] + [0]

    partialSum = 0
    ans = 0
    for a in A:
        if a == 0:
            ans += partialSum // 2
            partialSum = 0
        else:
            partialSum += a

    print(ans)

sol()

Solution (Python):
N = int(input())
A = list(int(input())for i in range(N))+[0]
ans = 0
for i in range(N):
    ans += A[i]//2
    if A[i] % 2== 1 and A[i+1] > 0:
        ans += 1
        A[i+1]-=1
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *

N = int(input())
A = [int(input()) for i in range(N)]
last, ans = 0, 0
for a in A:
    if a == 0:
        last = 0
    else:
        ans += (a+last)//2
        last = (a+last)%2
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = [int(input()) for _ in range(N)] + [0]



answer = 0
x = 0
for a in A:
    if a == 0:
        answer += x//2
        x = 0
    x += a

print(answer)

Solution (Python):
n=int(input())
a=[int(input()) for _ in range(n)]+[0]
ans=0
for i in range(n):
	ans+=a[i]//2
	a[i]=a[i]%2
	ans+=min(a[i],a[i+1])
	a[i+1]-=min(a[i],a[i+1])
print(ans)

Solution (Python):
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(N)]

ans = 0
for i in range(N):
    while A[i] >= 2:
        ans += A[i] // 2
        A[i] %= 2
    if i + 1 < N and A[i] >= 1 and A[i + 1] >= 1:
        A[i] -= 1
        A[i+1] -= 1
        ans += 1
print(ans)

Solution (Python):
n=int(input())
l=[int(input()) for i in range(n)]
ct=0
for i in range(n):
  ct+=l[i]//2
  l[i]%=2
  if i!=n-1 and l[i]==1 and l[i+1]!=0:
    ct+=1
    l[i]-=1
    l[i+1]-=1
print(ct)

Solution (Python):
N = int(input())
A = [0] * N
for i in range(N):
    A[i] = int(input())

ans = 0
for i in range(N):
    ans += A[i] // 2
    if A[i] % 2 == 1:
        if i + 1 < N:
            if A[i + 1] > 0:
                ans += 1
                A[i + 1] -= 1

print(ans)

Solution (Python):
N = int(input())
ans = 0
nums = [int(input()) for _ in range(N)]
for i in range(len(nums)):
    ans += nums[i]//2
    nums[i] %=  2
    if  i + 1 != N and nums[i]  > 0  and nums[i + 1] > 0:
        ans += 1
        nums[i] -= 1
        nums[i + 1] -= 1
print(ans)

Solution (Python):
n = int(input())
num_list = [ int(input()) for i in range(n) ]

ans = num_list[0] // 2
num_list[0] %= 2

for i in range(1,n):
    m = min(num_list[i-1], num_list[i])
    ans += m
    num_list[i-1], num_list[i] = num_list[i-1] - m, num_list[i] - m
    ans += num_list[i] // 2
    num_list[i] %= 2

print(ans)

Solution (Python):
N=int(input())
A=[int(input()) for i in range(N)]
t=0
p=0
for a in A:
    if a==0:
        t=0
    else:
        p+=(a+t)//2
        t=(a+t)%2
print(p)

Solution (Python):
N = int(input())
A = [int(input()) for _ in range(N)]

count = 0
tmp = 0
for i in range(N):
    if tmp == 1 and A[i] > 0: 
        count += 1
        A[i] -= 1
    count += A[i]//2 
    tmp = A[i]%2 

print (count)

Solution (Python):
N = int(input())
*A, = [int(input()) for _ in [0]*N]

B = []
i = 0
for j,a in enumerate(A):
    if a == 0:
        B.append(A[i:j])
        i = j+1
else:
    B.append(A[i:])

def f(C):
    L = len(C)
    if L==0:return 0
    elif L==1:return C[0]//2
    ret = [0]*2
    for i in (0,1):
        c0 = i
        ret[i]+= (C[0]-c0)//2+c0
        for c in C[1:-1]:
            ret[i] += (c-c0)//2
            c0 = (c-c0)%2
            ret[i] += c0
        ret[i] += (C[-1]-c0)//2
    return max(ret)

ans = sum(map(f,B))
print(ans)

Solution (Python):
N = int(input())

ans = 0
A = []
for _ in range(N):
    a = int(input())
    ans += a // 2
    if a % 2 == 1:
        A.append(1)
    elif a != 0:
        ans -= 1
        A.append(2)
    else:
        A.append(0)

a1 = 0
for a in A:
    if a > 0:
        a1 += a
    else:
        ans += a1 // 2
        a1 = 0

ans += a1 // 2

print(ans)

Solution (Python):
N = int(input())
a = [ int(input()) for i in range(N)]

ans = 0
for i in range(N):
        ans += a[i]//2
        a[i] %= 2
        if i != N - 1 and  a[i] > 0 and a[i+1] > 0:
            ans += 1
            a[i+1] -= 1
print(ans)

Solution (Python):
N=int(input())
A=[int(input()) for _ in range(N)]
cnt=0;ans=0
for i in range(N):
    if A[i] != 0:
        cnt+= A[i]
    else:
        ans+=(cnt//2)
        cnt=0
print(ans+cnt//2)

Solution (Python):
N = int(input())
A = [int(input()) for _ in range(N)]
ans = A[0] // 2
A[0] = A[0] % 2
for i in range(1, N):
    if A[i-1] > 0 and A[i-1] + A[i] >= 2:
        ans += 1; A[i] -= 1
    q, r = divmod(A[i], 2); A[i] = r
    ans += q
print(ans)

Solution (Python):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()

ans = 0
plus = 0
a = [ni() for _ in range(n)]

for ai in a:
    ans += ((ai+plus) // 2)
    plus = (ai+plus) % 2 if ai > 0 else 0

print(ans)

Solution (Python):
N = int(input())
A = [int(input()) for i in range(N)]

ans = 0
cnt = 0

for a in A :
    ans += (a+cnt) // 2
    if a == 0 :
        cnt = 0
    else :
        cnt = (a+cnt) % 2

print(ans)

Solution (Python):
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    ans = 0
    prev = 0
    for a in A:
        if prev and a:
            a -= 1
            ans += 1
        ans += a // 2
        prev = a % 2
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    ans = 0
    prev = 0
    for a in A:
        if prev and a:
            a -= 1
            ans += 1
        ans += a // 2
        prev = a % 2
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
A = [int(input()) for _ in range(N)]
ans = 0
tmp = 0

for i in A:
    if i != 0:
        tmp += i
    else:
        ans += tmp//2
        tmp = 0

ans += tmp//2

print(ans)

Solution (Python):
a = int(input())
count = 0
mod = 0
for i in range(a):
    b = int(input())
    if b == 0:
        mod = 0
    c = b + mod
    if not c==0:
        count += c//2
        mod = c%2
print(count)

Solution (Python):
from functools import reduce


N = int(input())
A = [int(input()) for _ in range(N)]


ans, _ = reduce(
    lambda acc, a: (
        acc[0] + (a + acc[1]) // 2,
        max(0, a - acc[1]) % 2
    ),
    A,
    (0, 0)
)


print(ans)

Solution (Python):
N = int(input())
ans = 0
flag = False
for i in range(N):
    a = int(input())
    if flag and a>0:
        a -= 1
        ans += 1
    ans += a//2
    if a % 2 == 0:
        flag = False
    else:
        flag = True

print(ans)

Solution (Python):
n = int(input())
a = [int(input()) for i in range(n)]
i = 0
cnt = 0
while i<n-1:
    cnt+=a[i]//2
    if a[i]%2 and a[i+1]:
        cnt+=1
        a[i+1]-=1
    i+=1
print(cnt+a[-1]//2)

Solution (Python):
n=int(input())
arr=[int(input()) for _ in range(n)]
ans=0
s=0
for i in range(n):
  if arr[i]!=0:
    s+=arr[i]
  else:
    ans+=s//2
    s=0
ans+=s//2
print(ans)

Solution (Python):
a,x=0,0
for i in range(int(input())):
    y=int(input())
    if y==0:x=0
    else:
        a+=(x+y)//2
        x=(x+y)%2
print(a)

Solution (Python):
n=int(input())
tmp, ans=0,0
for i in range(n):
  a=int(input())
  if a==0:
    ans+=tmp//2
    tmp=0
  else:
    tmp+=a
print(ans+tmp//2)

Solution (Python):
n = int(input())
a = [int(input()) for _ in range(n)]
ans = 0

for i in range(n-1):
    ans += a[i]//2
    if a[i]%2 == 1 and a[i+1] > 0:
        a[i+1]-=1
        ans += 1

ans += a[n-1]//2
print(ans)

Solution (Python):
n = int(input())
a = [int(input()) for i in range(n)]

ans = 0

for i in range(n-1):
    ans += a[i]//2
    if a[i]%2==1 and a[i+1]>0:
        a[i+1]-=1
        ans += 1

ans += a[n-1]//2

print(ans)

Solution (Python):


import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N = int(input())
L = [int(input()) for _ in range(N)]
ans = 0
prev = 0
for a in L:
    if a == 0:
        prev = 0
        continue

    a += prev
    ans += a//2
    prev = a % 2
print(ans)

Solution (Python):
N = int(input())
A = [int(input()) for _ in range(N)]

ans = 0
for i in range(N):
    ans += A[i] // 2
    if A[i] % 2:
        if i < N-1 and A[i+1]:
            ans += 1
            A[i+1] -= 1

print(ans)

Solution (Python):
n=int(input())
ans=0
res=0
for i in range(n):
  a=int(input())
  if res==1:
    if a==0:
      res=0
    elif a%2==0:
      ans+=a//2
      res=1
    else:
      ans+=(a+1)//2
      res=0
  else:
    ans+=a//2
    if a%2==1:
      res=1
print(ans)

Solution (Python):
N = int(input())
A = [int(input()) for i in range(N)]

ans = 0
for i in range(N):
    ans += A[i] // 2
    if A[i] % 2 == 1 and i+1 < N and A[i+1] > 0:
        A[i+1] -= 1
        ans += 1

print(ans)

Solution (Python):

import sys


def solve(N: int, A: "List[int]"):
    mochikoshi = 0
    res = 0
    for a in A:
        p, q = divmod(a + mochikoshi, 2)
        res += p
        if p == 0 and mochikoshi == 1:
            mochikoshi = 0
        else:
            mochikoshi = q
    print(res)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [ int(next(tokens)) for _ in range(N) ]  
    solve(N, A)

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
ans,b = 0,0
for i in range(n):
    a = int(input())
    if a != 0:
        b += a
    else:
        ans += b//2
        b = 0
    if i == n-1:
        ans += b//2
print(ans)

Solution (Python):
N = int(input())
A = [int(input()) for i in range(N)]
array = []
ans = 0
j = 0

for i in range(N):
  if i+1 == N:
    ans += sum(A[j:i+1])//2
    j = i+1
  elif A[i+1] == 0:
    ans += sum(A[j:i+1])//2
    j = i+1
    
print(ans)

Solution (Python):
from functools import reduce


N = int(input())
A = [int(input()) for _ in range(N)]


ans = reduce(
    lambda acc, a: (acc[0] + (a + acc[1]) // 2, max(0, a - acc[1]) % 2),
    A,
    (0, 0)
)[0]


print(ans)

Solution (Python):
n,*a=map(int,open(0).read().split())

ans=0

for i in range(n-1):
    ans+=a[i]//2
    if a[i]%2==1 and a[i+1]>0:
        ans+=1
        a[i+1]-=1
    
ans+=a[n-1]//2

print(ans)

Solution (Python):
n=int(input())
ans=chk=0
for i in range(n):
    a=int(input())
    ans+=(a+chk)//2
    if a>0:
         chk=(a+chk)%2
    else:
        chk=0
print(ans)

Solution (Python):
n=int(input())
a=[int(input()) for i in range(n)]
b=0
c=0
for i in a:
    if i!=0:
        c+=i
    else:
        b+=c//2
        c=0
print(b+c//2)

Solution (Python):
n = int(input())
a = [int(input()) for _ in range(n)]
ans = 0
l = r = 0
while l < n:
    s = 0
    while r < n and a[r] > 0:
        s += a[r]
        r += 1
    ans += s // 2
    l = r + 1
    r = l
print(ans)

Solution (Python):
N = int(input())
card = []
for i in range(N):
    card.append(int(input()))
card.append(0)
ans = 0
for i in range(N):
    pair = card[i] // 2
    ans += pair
    card[i] -= pair * 2
    if card[i] == 1 and card[i+1] > 0:
        card[i] -= 1
        card[i+1] -= 1
        ans += 1
print(ans)

Solution (Python):
N = int(input())
ans = 0
prev = 0
for _ in range(N):
    A = int(input())
    if A == 0:
        prev = 0
        continue
    A += prev
    ans += A // 2
    prev = A % 2
print(ans)

Solution (Python):
N = int(input())
ans = 0
prev = 0
for _ in range(N):
    A = int(input())
    if A == 0:
        prev = 0
        continue
    A += prev
    ans += A // 2
    prev = A % 2
print(ans)

Solution (Python):
N=int(input())
A=[int(input()) for i in range(N)]

res=0
cnt=0
for i in range(N):
    if A[i]==0:
        res+=cnt
        cnt=0
    else:
        cnt=(cnt+(A[i]%2))%2
res+=cnt
print((sum(A)-res)//2)

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from collections import Counter

def main():
    N = II()
    A = []
    for _ in range(N):
        A.append(II())
    ans = 0
    tmp = 0
    for a in A:
        if a > 0:
            tmp += a
        else:
            ans += tmp // 2
            tmp = 0
    ans += tmp // 2

    return ans

print(main())

Solution (Python):
n = int(input())
a = [int(input()) for _ in range(n)]
pairs = 0
for i in range(n-1):
  pairs += a[i]//2
  a[i] %= 2
  if a[i]:
    syu = min(a[i],a[i+1])
    a[i+1] -= syu
    pairs += syu
pairs += a[-1]//2
print(pairs)

Solution (Python):
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))
A.append(0)
ans = 0
for j in range(N):
  ans += A[j]//2
  if A[j]%2 != 0 and A[j+1] != 0:
    A[j+1] += 1
print(ans)

Solution (Python):
n = int(input())
a = [int(input()) for _ in range(n)]
cnt = 0
for i in range(n):
    if i != n-1 and a[i] % 2 == 1:
        if a[i+1] != 0:
            a[i+1] -= 1
            cnt += 1
    cnt += a[i]//2
print(cnt)

Solution (Python):
n = int(input())
alist = [int(input()) for _ in range(n)]

np = 0
remain = 0
for a in alist:
  if a == 0:
    remain = 0
  elif remain == 0:
    np += a // 2
    remain = a % 2
  else:
    np += (a + remain) // 2
    remain = (a + remain) % 2
print(np)

Solution (Python):
N = int(input())
ans = 0
c = 0
for i in range(N):
	A = int(input())
	ans += int((A + c) // 2)
	if A >= 2 and (A + c) % 2 != 0:
		c = 1
	else:
		c = 0

print(ans)

Solution (Python):
n=int(input())
A=[int(input()) for _ in range(n)]
cnt=0
for i in range(n-1):
    cnt+=A[i]//2
    if A[i]%2 and A[i+1]:
        cnt+=1
        A[i+1]-=1
cnt+=A[-1]//2
print(cnt)

Solution (Python):
n = int(input())
a = [int(input()) for i in range(n)]
ans = 0
tmp = 0
for i in a:
  if i == 0:
    ans += tmp // 2
    tmp = 0
  else:
    tmp += i
ans += tmp // 2
print(ans)

Solution (Python):
n=int(input())
c=0
d=0
for i in range(n):
    b=int(input())
    if b!=0:
        d+=b
    else:
        c+=d//2
        d=0
print(c+d//2)

Solution (Python):
N=int(input())
A=[int(input()) for _ in range(N)]

ans=0
idx=[]
for i in range(N):
  if A[i]==0:
    idx.append(i+1)
n=0
idx.append(N)
for iidx in idx:
  ans+=sum(A[n:iidx])//2
  n=iidx
print(ans)

Solution (Python):


import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = [II() for _ in range(n)]

    res = 0
    mod = 0
    for a in A:
        if not a:
            mod = 0
            continue
        q, mod = divmod(a + mod, 2)
        res += q

    return res


print(main())

Solution (Python):
n = int(input())
a = [int(input()) for i in range(n)]
ans = 0
for i in range(n-1):
    if a[i]%2 and a[i+1]:
        a[i+1] -= 1
        ans += 1
    ans += a[i]//2
ans += a[-1]//2
print(ans)

Solution (Python):
n = int(input())
a = [int(input()) for i in range(n)]
ans = 0
for i in range(n-1):
  if a[i]>=2:
    ans += a[i]//2
    a[i] = a[i]%2
  if a[i]==1:
    if a[i+1]>=1:
      ans += 1
      a[i] -= 1
      a[i+1] -=1
ans = ans +a[n-1]//2
print(ans)

Solution (Python):
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [long(input_raw[0])]
    A = []
    for i in range(N):
        input_raw = read_func().strip().split()
        A.append(long(input_raw[0]))

    s = 0
    count = 0
    for i in range(N):
        if A[i] != 0:
            s += A[i]
        else:
            count += s/2
            s = 0
    count += s/2

    print count



if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
A = list(int(input()) for i in range(N))

ans = 0
for i in range(N) :
    ans += A[i]//2
    if i != N-1 :
        if A[i+1] >= 1 :
            A[i+1] += A[i] % 2
print(ans)

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]
A.append(0)


ans = 0
tmp = 0
for a in A:
    if a == 0:
        ans += tmp//2
        tmp = 0
    else:
        tmp += a
print(ans)

Solution (Python):
n = int(input())
a = [int(input()) for _ in range(n)]
a.append(0) 
donnyoku = 0
for i in range(n):
  pair = (a[i]+a[i+1])//2
  donnyoku += pair
  a[i+1] -= max(0,2*pair-a[i])
print(donnyoku)

Solution (Python):
N = int(input())
ans = 0

A = list(int(input()) for i in range(N))

for i in range(N) :
    ans += A[i]//2
    if i != N-1 :
        if A[i] >= 2 :
            A[i+1] += A[i]%2
print(ans)

Solution (Python):
n = int(input())
a = [int(input()) for _ in range(n)]

ans = 0
for i in range(n):
    ans += a[i] // 2
    if a[i] % 2 == 1 and i+1 < n:
        if a[i+1] > 0:
            a[i+1] -= 1
            ans += 1
            
print(ans)

Solution (Python):
def inpl(): return list(map(int, input().split()))
N = int(input())
C = [int(input()) for _ in range(N)] + [0]
ans = 0
for k in range(N):
    c = C[k]
    ans += c//2
    if c%2 and C[k+1]:
        ans += 1
        C[k+1] -= 1
print(ans)

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**8) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


n = ni()
a = [ni() for _ in range(n)]

cnt = {i+1: ai for i, ai in enumerate(a)}

prev = -100
cur = 0
ans = 0
for key in sorted(cnt.keys()):
    if cnt[key] == 0:
        continue
    
    if prev == -100:
        prev = key
    
    if (key-prev) < 2:
        cur += cnt[key]
    else:
        cur = cnt[key]
        
    ans += cur // 2
    cur -= 2 * (cur//2)
    
    prev = key
        
print(ans)

Solution (Python):
N = int(input())
A = [int(input()) for i in range(N)]
rem = 0
ans = 0
for a in A:
    ans += (rem+a)//2
    rem = 0 if a==0 else (rem+a)%2
print(ans)

Solution (Python):
s=t=0
for _ in[0]*int(input()):a=int(input());s+=(a+t)//2;t=(a+t)%2&(a>0)
print(s)

Solution (Python):
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
num = A[0] // 2
for i in range(1, N):
    if A[i] >= 1:
        A[i] += A[i - 1] % 2
    num += A[i] // 2

print(num)

Solution (Python):
N = int( input())
A = [ int( input()) for _ in range(N)]
now = 0
ans = 0
for i in range(N):
    a = A[i]
    if now == 1:
        if a >= 1:
            ans += 1
            a -= 1
    now = 0
    ans += a//2
    a = a - a//2*2
    if a == 1:
        now = 1
print( ans)

Solution (Python):
n = int(input())
d = []
for i in range(n):
    d.append(input())

a = [int(m) for m in d]
ans = 0
for i in range(n):
    if i == n - 1:
        ans += a[i] // 2
    else:
        ans += a[i] // 2
        ans += (a[i + 1] + a[i] % 2) // 2
        if a[i + 1] > 0:
            a[i + 1] = a[i + 1] + a[i] % 2 - ((a[i + 1] + a[i] % 2) // 2) * 2
        else:
            a[i + 1] = 0
print(ans)

Solution (Python):
N = int(input())
a_list = [int(input()) for _ in range(N)]
split_a_list = []

pre = -1
for i, a in enumerate(a_list):
    if a == 0:
        split_a_list.append(sum(a_list[pre + 1:i]))
        pre = i
else:
    split_a_list.append(sum(a_list[pre + 1:N]))
ans = 0
for s in split_a_list:
    ans += s // 2
print(ans)

Solution (Python):
N = int(input())
count = 0
ans = 0
for i in range(N):
    a = int(input())
    if a:
        count += a
    else:
        ans += count // 2
        count = 0
ans += count // 2
print(ans)

Solution (Python):
a = int(input())
s = 0
p =[int(input()) for _ in range(a)]
p.append(0)
for i in range(a):
    s +=p[i]//2
    if p[i+1] >=1 and p[i]%2 == 1:
        s +=1
        p[i+1] -=1
    
print(s)

Solution (Python):
n = int(input())
a = [int(input()) for _ in range(n)]
a.append(0)

res = 0
for i in range(n):
    
    res += a[i] // 2
    a[i] %= 2
    if a[i]==1 and a[i+1]!=0:
        res += 1
        a[i] -= 1
        a[i+1] -= 1
print(res)

Solution (Python):
n = int(input())
ans = 0
bonus = 0
for i in range(n):
    inpt = int(input())
    if inpt == 0:
        ans += 0
        bonus = 0
    else:
        sho, yo = divmod(inpt+bonus, 2)
        ans += sho
        bonus = yo

print(ans)

Solution (Python):



def main():
    n = int(input())
    a = [int(input()) for _ in range(n)][::-1]
    ans = 0

    for i in range(n):
        p, q = divmod(a[i], 2)
        ans += p

        if q == 1:
            if (i + 1 <= n - 1) and (a[i + 1] >= 1):
                ans += 1
                a[i + 1] -= 1

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


N = int(input())
a = []
for _ in range(N):
    a.append(int(input()))


ans = 0
for i in range(N):
    if a[i] % 2 == 0:
        ans += a[i] // 2
    else:
        if (i == N-1) or (a[i+1] == 0):
            ans += a[i] // 2
        else:
            ans += (a[i] // 2) + 1
            a[i+1] -= 1

print(ans)

Solution (Python):
N=int(input())
A=[int(input()) for i in range(N)]
ans=0
s=0
for i in range(N):
    ans+=A[i]//2
    s=A[i]-2*(A[i]//2)
    if i!=N-1 and A[i+1]!=0 and s!=0:
        A[i+1]-=s
        ans+=1
    
print(ans)

Solution (Python):
N=int(input())
A=[int(input()) for i in range(N)]
ans=sum(A)
if N==1:
  print(A[0]//2)
  exit()
for i in range(N-1):
  if A[i]%2==A[i+1]%2:
    A[i]=0
    A[i+1]=0
  elif A[i]%2==1 and A[i+1]==0:
    A[i]=1
  else:
    A[i]=0
    A[i+1]=1    
for i in range(N):
  ans-=A[i]
print(ans//2)

Solution (Python):
n = int(input())
moto =[]
a = []
for _ in range(n):
  b = int(input())
  moto.append(b)
  if b%2 == 1:
    a.append(1)
  elif b:
    a.append(2)
  else:
    a.append(0)
for i in range(n-1):
  if a[i]%2 == 1:
    if a[i+1]:
      a[i+1] += 1
      a[i+1] %=2
      a[i]-=1
for i in range(n):
  a[i] %=2
print((sum(moto)-sum(a))//2)

Solution (Python):
n = int(input())
a = [int(input()) for _ in range(n)]

res = 0
for i in range(n):
    res += a[i] // 2
    a[i] %= 2
    if i!=n-1:
        if a[i] and a[i+1]:
            res += 1
            a[i] -= 1
            a[i+1] -= 1
print(res)

Solution (Python):
n = int(input())
a = [int(input()) for _ in range(n)]

ret = 0

for i in range(n):
    if a[i] == 0:
        continue
    b = a[i] // 2
    if a[i] % 2 == 0:
        ret += b - 1
        a[i] = 2
    else:
        ret += b
        a[i] = 1

for i in range(n-1):
    if a[i] == 1 and a[i+1] > 0:
        ret +=1
        a[i+1] -= 1
    if a[i] == 2:
        ret += 1

if a[-1] == 2:
    ret += 1
print(ret)

Solution (Python):
N = int(input())
A = [int(input()) for i in range(N)]

ans = rem = 0
for a in A:
    if a == 0:
        rem = 0
        continue
    a += rem
    ans += a//2
    rem = a%2
print(ans)

Solution (Python):
N = int(input())
Ans = 0
Rem = False
for i in range(N):
    A = int(input())
    if A > 0:
        if Rem:
            Ans += (A-1)//2 + 1
            Rem = (True if (A-1)%2 == 1 else False)
        else:
            Ans += A//2
            Rem = (True if A%2 == 1 else False)
    else: Rem = False
print(Ans)

Solution (Python):
n = int(input())
a = [int(input()) for _ in range(n)]
res = 0
for i in range(n):
    res += a[i] // 2
    a[i] %= 2
    if i!=n-1 and a[i]==1 and a[i+1]!=0:
        a[i] -= 1
        a[i+1] -= 1
        res += 1
print(res)

Solution (Python):
N = int(input())
ctr = 0
ans = 0
for _ in range(N):
    i = int(input())
    ctr += i
    if not i:
        ans += ctr//2
        ctr = 0
ans += ctr//2

print(ans)

Solution (Python):

N=int(input())

A = []

for i in range(N):
    A.append(int(input()))

count=0    
prev_wait = 0
for i in range(N):
    if A[i]>=1:
        count+=int((prev_wait+A[i])/2)
        prev_wait = (A[i]+prev_wait)%2
    else:
        prev_wait = 0
        
print(count)

Solution (Python):

n = int(input())
cnt = 0
s = 0
for _ in range(n):
    x = int(input())
    if x==0:
        cnt += s//2
        s = 0
    else:
        s += x
print(cnt+s//2)

Solution (Python):
n = int(input())
a = [int(input()) for i in range(n)]
ans = 0
for i in range(n):
    if a[i] % 2 == 0:
        ans += a[i] // 2
    else:
        if i != n - 1 and a[i + 1] > 0:
            a[i + 1] -= 1
            a[i] += 1
        ans += a[i] // 2
print(ans)

Solution (Python):
N = int(input())
lis=[]
for i in range(N):
  lis.append(int(input()))
ans = 0
stack = 0
for nums in lis:
  if nums > 0:
    stack += nums
  else:
    ans += stack//2
    stack = 0
ans += stack//2
print(ans)

Solution (Python):
n = int(input())
lis = [int(input()) for i in range(n)]
cou = 0
num = 0
for i in range(n):
  if lis[i] == 0:
    cou += (num // 2)
    num = 0
  else:
    num += lis[i]
cou += (num // 2)
print(cou)

Solution (Python):
N = int(input())

ans = 0
prev = 0

for i in range(N):
  a = int(input())
  if prev == 1 and a >= 1:
    ans += 1
    a -= 1
  
  ans += a // 2
  prev = a%2
    
print(ans)

Solution (Python):
n = int(input())

a = []

f = [0 for i in range(n)]

ans = 0

for i in range(n):
    m = int(input())
    if m > 1:
        f[i] = 1
    ans += m//2
    a.append(m%2)

for i in range(n):
    if a[i] == 1 and i != n-1:
        if a[i+1] == 1:
            ans += 1
            a[i+1] = 0
        elif f[i+1] == 1:
            a[i+1] = 1
            
print(ans)

Solution (Python):
t=c=0
for _ in[0]*int(input()):i=int(input());c+=(i+t)//2;t=(i+t)%2&(i>0)
print(c)

Solution (Python):
t=c=0
for _ in[0]*input():
 i=input()
 if i:t+=i 
 else:c+=t/2;t=0
print c+t/2

Solution (Python):
t=c=0
for _ in[0]*input():i=input();c+=(i+t)/2;t=(i+t)%2&(i>0)
print c

Solution (Python):
n=int(input())
a=[int(input()) for i in range(n)]
count=0
for i in range(n):
    if a[i]>1:count+=a[i]//2
    if i==n-1:continue
    if a[i]%2==1 and a[i+1]>0:
        count+=1
        a[i+1]-=1
print(count)

Solution (Python):
N=int(input())
ans=0
A=int(input())
ans+=int(A/2)
A=A%2
for i in range(N-1):
    B=int(input())
    if B==0:
        A=0
    else:
        if A==1:
            B=B-1
            ans+=1
            ans+=int(B/2)
            A=B%2
        else:
            ans+=int(B/2)
            A=B%2
            
print(ans)

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
aa = [int(input()) for i in range(N)]

ans = aa[0]//2
aa[0] %= 2
for i in range(1,N):
    if aa[i-1] > 0 and aa[i] > 0:
        aa[i-1] -= 1
        aa[i] -= 1
        ans += 1
    ans += aa[i]//2
    aa[i] %= 2
    
print(ans)

Solution (Python):
n = int(input())
a = []
for i in range(n):
    temp = int(input())
    a.append(temp)

counter = 0
for i in range(n):
    counter += a[i]//2
    a[i] = a[i]%2
    if a[i] == 1:
        if i != n-1 and a[i+1] > 0:
            a[i] += -1
            a[i+1] += -1
            counter += 1
print(counter)

Solution (Python):
N = int(input())
a = [int(input()) for i in range(N)]
cnt=0
for i in range(N):
    if a[i]//2 >=1:
        cnt+=a[i]//2
        a[i]-=a[i]//2*2
    if i!=N-1:
        if a[i+1]>=1 and a[i]==1:
            cnt+=1
            a[i+1]-=1
            a[i]-=1
print(cnt)

Solution (Python):
N = int(input())
A = [int(input()) for _ in range(N)]
ans = 0
for i in range(N - 1):
    p, q = divmod(A[i], 2)
    ans += p
    if q and A[i + 1]:
        A[i + 1] += 1
ans += A[-1] // 2
print(ans)