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())
cards = [0] + [int(input()) for i in range(N)] + [0]
ans = 0
for i in range(N+1):
  min1 = min(cards[i-1],cards[i])
  ans += min1
  cards[i] -= min1
  
  ans += cards[i]//2
  cards[i] -= cards[i]//2*2
  
  min2 = min(cards[i],cards[i+1])
  ans += min2
  cards[i] -= min2
  cards[i+1] -= min2
  
print(ans)

Solution (Python):
def examB():
    N = I(); A = [I() for _ in range(N)]
    ans = 0; cur= 0
    for i in A:
        if i==0:
            ans += cur//2
            cur = 0
        else:
            cur += i
    ans += cur // 2
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examB()

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

Solution (Python):
N = int(input())
A = [int(input()) for _ 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):
n = int(input())
a = [0]
for _ in range(n):
    a.append(int(input()))

ans = 0
for i in range(n):

    
    ans += a[i] // 2
    a[i] -= a[i] // 2 * 2

    
    ans += min(a[i], a[i + 1])
    a[i + 1] -= min(a[i], a[i + 1])

else:  
    ans += a[-1] // 2

print(ans)

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

ret = 0
for i in range(N) :
    if A[i] > 2 :
        x = (A[i] - 1) // 2
        ret += x
        A[i] -= x * 2

for i in range(N - 1) :
    if A[i] == 2 :
        ret += 1
    elif A[i] == 1 and A[i + 1] >= 1 :
        ret += 1
        A[i + 1] -= 1

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

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

if a.count(0)==0:
    print(sum(a)//2)
else:
    tmp_sum=0
    ans=0
    for i in range(n):
        if a[i]==0:
            ans+=tmp_sum//2
            tmp_sum=0
        else:
            tmp_sum+=a[i]
    ans+=tmp_sum//2

    print(ans)

Solution (Python):
N=int(input())
ans=0
re=0
for _ in range(N):
  a=int(input())
  if a%2==0:
    ans+=a//2
    if a==0:
      re=0
  else:
    if re==1:
      ans+=a//2+1
      re=0
    else:
      ans+=a//2
      re=1
      
print(ans)

Solution (Python):
N=int(input())
A=[0]
for i in range(1,N+1):
    A.append(int(input()))

ans=0
i=1
while i<=N:
    
    
    if A[i]>=2:
        ans+=A[i]//2
        A[i]%=2
    
    if i<N and A[i]==1 and A[i+1]>=1:
        ans+=1
        A[i]-=1
        A[i+1]-=1
    
    
    i+=1

print(ans)

Solution (Python):
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = [int(readline()) for _ in range(n)]
    c = ac = 0
    for v in a:
        c += v
        if v == 0:
            ac += c // 2
            c = 0
    print(ac + c // 2)


if __name__ == '__main__':
    solve()

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

n=int(input())
l=[int(input()) for _ in range(n)]
ans=0
re=0
for i in l:
    if i==0:
        re=0
    ans+=(i+re)//2
    re=(i+re)%2
print(ans)

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

N, *A = map(int, read().split())

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

answer += A[-1] // 2
print(answer)

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

N, *A = map(int, read().split())

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

answer = sum([i // 2 for i in A])
print(answer)

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

Solution (Python):

n=int(input())
modlists=[0]*(n+1)
for  i in range(n):
    s=int(input())
    modlists[i]=s
add=0
lefted=0
for i in range(n):
    if modlists[i]!=0:
        add+=modlists[i]
    elif modlists[i]==0:
        lefted+=add%2
        add=0
sums=sum(modlists)
print((sums-lefted)//2)

Solution (Python):
import numpy as np
import fractions
N = int(input())
a = [int(input()) for i in range(N)]
res = 0
flg = 0
for i in range(N):
    if flg == 1 and a[i] >= 1:
        res += 1
        flg = 0
        a[i] -= 1
    if flg == 1:
        flg = 0
    res += a[i]//2
    a[i] -= (a[i]//2)*2
    if a[i] == 1:
        flg = 1
print(res)

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

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

Solution (Python):
n=int(input())
a=[]
for _ in range(n):
  a.append(int(input()))
i=0
c=0
ans=0
while i<=n-1:
  if a[i]==0:
    ans+=c//2
    i=i+1
    c=0
  else:
    c+=a[i]
    i=i+1
ans+=c//2
print(ans)

Solution (Python):
def main():
    N = int(input())
    A = [0] * (N + 1)
    cnt = 0
    for i in range(N):
        A[i] = int(input())

    for i in range(N):
        cnt += A[i] // 2
        A[i] %= 2

        if A[i] > 0 and A[i+1] > 0:
            cnt += 1
            A[i] -= 1
            A[i+1] -= 1

    print(cnt)


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
lst = list()
cnt = 0
for _ in range(N):
    a = int(input())
    if a == 0:
        lst.append(cnt)
        cnt = a
    else:
        cnt += a
lst.append(cnt)

ans = 0
for cnt in lst:
    ans += cnt // 2
print(ans)

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



def main():
    N = int(input())
    ans = 0
    x = 0
    for i in range(N):
        a = int(input())
        if a == 0:
            ans += x//2
            x = 0
        else:
            x += a
    ans += x//2
    print(ans)


if __name__ == '__main__':
    main()

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


def main():
    N = int(input())
    carry = 0
    ans = 0
    for i in range(N):
        x = int(input())
        if carry and x > 0:
            ans += 1  
            d, m = divmod(x - 1, 2)
            ans += d
            carry = m
        else:
            d, m = divmod(x, 2)
            ans += d
            carry = m
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

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

ans = 0

for i in range(n-1):
    if a[i]&1:
        ans += a[i]//2
        a[i] = 1
    elif a[i] ==0:
        pass
    else:
        ans += a[i]//2-1
        a[i] = 2

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

Solution (Python):



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

ans = 0
"""
for i in range(n-1):
    if a[i]&1:
        ans += a[i]//2
        a[i] = 1
    elif a[i] ==0:
        pass
    else:
        ans += a[i]//2-1
        a[i] = 2
print(a)
print(ans)
"""
for i in range(n-1):
    ans += a[i]//2
    a[i] -= (a[i]//2)*2
    ad = min(a[i],a[i+1])
    ans += ad
    a[i+1] -= ad

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

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

ans = 0
for i in range(N):
  if A[i] >= 2:
    ans += A[i]//2
    A[i] -= (A[i]//2)*2
  if i < N-1:
    m = min(A[i],A[i+1])
    ans += m
    A[i] -= m
    A[i+1] -= m
  
print(ans)

Solution (Python):
n = int(input())
a_ls = []
for i in range(n):
    a_ls.append(int(input()))
flg = False
cnt = 0
for a in a_ls:
    if flg:
        a += 1
    cnt += a // 2
    if flg and a == 1:
        flg = False
    else:
        flg = True if a % 2 == 1 else False
print(cnt)

Solution (Python):

n=int(input())
modlists=[0]*(n+1)
for  i in range(n):
    s=int(input())
    modlists[i]=s
add=0
lefted=0
for i in range(n):
    if modlists[i]!=0:
        add+=modlists[i]
    elif modlists[i]==0:
        lefted+=add%2
        add=0
sums=sum(modlists)
print((sums-lefted)//2)

Solution (Python):
n=int(input())
c=0
ans=0
for i in range(n):
    s=int(input())
    ans+=(c+s)//2
    c=(c+s)%2
    if s==0:
        c=0
print(ans)

Solution (Python):
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)

from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque



def main():
    num = int(input())
    data = [int(input()) for i in range(num)]

    ans = 0
    for i in range(num):
        if i == 0:
            ans += data[i] // 2
            data[i] = data[i] % 2
        else:
            ans += (data[i] + data[i - 1]) // 2
            if data[i] != 0:
                data[i] = (data[i] + data[i - 1]) % 2
    print(ans)



if __name__ == '__main__':
    main()

Solution (Python):

N = int(input())

A = []

for i in range(N):

    a = int(input())

    A.append(a)

ans = 0
amari = 0

for i in range(N):

    ans += (A[i] + amari) // 2

    if A[i] == 0:
        amari = 0
    else:
        amari = (A[i] + amari) % 2
        
print (ans)

Solution (Python):


N = int(input().split()[0])
a_list = []

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

c = 0

for i in range(N):
    before = a_list[i - 1] if i != 0 else 0

    c += (before + a_list[i]) // 2
    a_list[i] = (before + a_list[i]) % 2 if a_list[i] != 0 else 0

ans = c
print(ans)

Solution (Python):
N = int(input())
A = [int(input()) for _ in range(N)]
m = 0
ans = 0
for i in A:
  num = i + m
  d = num // 2
  if num % 2 == 0 or i == 0:
    m = 0
  else:
    m = 1
  ans += d

print(ans)

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

ans = 0

for i, a in enumerate(A):
    ans += a // 2
    A[i] = a % 2
    if i < N-1 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())
a = [0] * n
for i in range(n):
  a[i] = int(input())
c = 0
for i in range(n-1):
  c += a[i] // 2
  if a[i] % 2 == 1:
    if a[i+1] != 0:
      c += 1
      a[i+1] -= 1
c += a[-1] // 2
print(c)

Solution (Python):


n=int(input())















a=[int(input())for _ in range(n)]
ans=0
total=0
noncardin_judge=False
for i in range(n):
    total+=a[i]
    if a[i]==0:
        ans+=total//2
        total=0
        noncardin_judge=True
if noncardin_judge:
    print(ans+total//2)
else:
    print(sum(a)//2)

Solution (Python):


n=int(input())















a=[int(input())for _ in range(n)]
ans=0
total=0
judge=False
for i in range(n):
    total+=a[i]
    if a[i]==0:
        ans+=total//2
        total=0
        judge=True
if judge:
    print(ans+total//2)
else:
    print(sum(a)//2)

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

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

    ans+=a[i]//2
        
    if a[i]%2 != 0:
        li[i]=1
print(ans)

Solution (Python):
import sys
input=sys.stdin.readline
N = int(input())











ans = 0
sum_a = 0
for i in range(N):
  a = int(input())
  sum_a += a
  if(a == 0):
   ans += sum_a//2
   sum_a = 0
ans += sum_a//2
print(ans)

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

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

ans = 0
rest = 0
for v in a:
    q, rest = divmod(v + rest, 2)
    ans += q
    
    if v == 0:
        rest = 0

print(ans)

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

n=int(input())
a=[int(input()) for _ in range(n)]
ans=0
s=0
for i in range(n):
    s+=a[i]
    if a[i]==0:
        ans+=(s//2)
        s=0
ans+=(s//2)
print(ans)

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

n=int(input())
a=[int(input()) for _ in range(n)]
ans=0
s=0
for i in range(n):
    s+=a[i]
    if a[i]==0:
        ans+=(s//2)
        s=0
ans+=(s//2)
print(ans)

Solution (Python):
N,*A=map(int,open(0));p=f=0
for a in A:p+=(a+f)//2;f=(a+f)%2&(a>0)
print(p)

Solution (Python):
N,*A=map(int,open(0));p=f=0
for a in A:d,m=divmod(a+f,2);p+=d;f=m&(a>0)
print(p)

Solution (Python):
N,*A=map(int,open(0));p=f=0
for a,b in zip(A,A[1:]):d,m=divmod(a-f,2);f=min(m,b);p+=d+f
print(p+(A[-1]-f)//2)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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 I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[I() for _ in range(n)]
  sm=0
  ans=0

  for x in l:
    if x==0:
      ans+=sm//2
      sm=0
    else:
      sm+=x
  ans+=sm//2
  return ans


print(main())

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
A = IR(n)
ans = 0
cur = 0
for i in range(n):
    if not A[i]:
        cur = 0
    else:
        if cur % 2:
            ans += 1
            A[i] -= 1
        ans += A[i] // 2
        cur = A[i] % 2


print(ans)

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

count=0

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


for i in range(n-1):
    count+=a[i]//2
    a[i]=a[i]%2
    if((a[i]>0) & (a[i+1]>0)):
        MinNum=min(a[i],a[i+1])
        a[i]-=MinNum
        a[i+1]-=MinNum
        count = count+MinNum


count+=a[n-1]//2
a[n-1]=a[n-1]%2

print(count)

Solution (Python):
n=int(input())
b=int(input())
a=b//2;b%=2
for i in range(n-1):
  c=int(input())
  t=(b+c)//2
  a+=t
  b=c-max(0,t*2-b)
print(a)

Solution (Python):
N = int(input())
r = 0
cnt = 0
for i in range(N):
    A = int(input())
    cnt += (A + r)//2
    if A == 0:
        r = 0
    else:
        r = (A + r) % 2
print(cnt)

Solution (Python):

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

ans = 0
tmp = 0

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

print(ans)

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

    
b=0
listb=[]
for i in range(n):
    if lista[i]!=0:
        b+=lista[i]
    elif lista[i]==0:
        listb.append(b)
        b=0
listb.append(b)


listb=list(map(lambda x: x//2,listb))
print(sum(listb))

Solution (Python):
n=int(input())
a=[]
for i in range(n):
	x=int(input())
	a.append(x)
ans=0
for i in range(n-1):
	if a[i]>0:
		ans+=(a[i]//2)
		a[i]-=(a[i]//2)*2
	if a[i]>0:
		a[i+1]-=min(a[i],a[i+1])
		ans+=min(a[i],a[i+1])
if a[-1]>0:
	ans+=a[-1]//2
print(ans)

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

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


if A[-1]:
  ans+=A[-1]//2
print(ans)

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


print(ans)

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

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST(N)

ans = cnt = 0
for i in range(N):
    if A[i] == 0:
        ans += cnt // 2
        cnt = 0
    else:
        cnt += A[i]
ans += cnt // 2

print(ans)

Solution (Python):
from sys import stdin, exit
N = int(stdin.readline().rstrip())
A = [int(stdin.readline().rstrip()) for _ in range(N)]
tmp_sum = 0
ans = 0
idx = 0
for i, a in enumerate(A):
    if a == 0:
        ans += (tmp_sum // 2)
        idx = i
        tmp_sum = 0
    else:
        tmp_sum += a
        if i == N-1:
            ans += (tmp_sum // 2)
print(ans)

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST(N)

ans = A[0] // 2
mod = A[0] % 2
for i in range(1, N):
    ans += A[i] // 2
    tmpmod = A[i] % 2
    if mod == tmpmod == 1:
        ans += 1
        mod = 0
    elif tmpmod == 1:
        mod = 1
    elif A[i] == 0:
        mod = 0
print(ans)

Solution (Python):

def main():
    
    N, *A = map(int, open(0).read().split())
    A.append(0)
    ans, cur = 0, 0
    for i in A:
        if i:
            cur += i
        else:
            ans += cur // 2
            cur = 0
    print(ans)


if __name__ == "__main__":
    main()

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

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

for i in range(N-1):
    if A[i] == 1 and (A[i+1] == 1 or A[i+1] == 2):
        A[i+1] -= 1
        ans += 1
    elif A[i] == 2:
        ans += 1

if A[-1] == 2:
    ans += 1

print(ans)

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

l=0
cnt=0

for i in range(n):
  if A[i]==0:
    cnt+=(sum(A[l:i]))//2
    l=i+1
  elif i==n-1:
    cnt+=(sum(A[l:n+1]))//2
print(cnt)

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


def count_pairs(a_list):
    count = 0
    if len(a_list) == 0:
        return 0
    if len(a_list) == 1:
        return a_list[0] // 2
    for index in range(len(a_list)):
        if not index == len(a_list)-1:
            pairs = a_list[index] // 2
            count += pairs
            a_list[index] -= pairs*2

            pairs = min(a_list[index], a_list[index + 1])
            a_list[index + 1] -= pairs
            a_list[index] -= pairs
            count += pairs
        else:
            count += a_list[index] // 2

    return count

a_sub_list = []
count = 0
for _ in range(N):
    a = int(input())
    if a == 0:
        count +=count_pairs(a_sub_list)
        a_sub_list = []
    else:
        a_sub_list.append(a)


count += count_pairs(a_sub_list)

print(count)

Solution (Python):


import sys
input=sys.stdin.readline

n=int(input())
cnt=0
pre=0
for i in range(n):
    a=int(input())
    if a==0:
        pre=0
        continue
    if pre:
        cnt+=1            
        a-=1
    buf=a//2
    a-=buf*2
    cnt+=buf
    pre=a

print(cnt)

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

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

Solution (Python):
N = int(input())
As = []
for i in range(N):
  A = int(input())
  As.append(A)
r = 0
c = 0
for A in As:
  if A == 0:
    r += c//2
    c = 0
  else:
    c += A
r += c//2
print(r)

Solution (Python):
import sys,bisect,heapq

mod = 10**9+7
dd = ((-1, 0), (0, -1), (1, 0), (0, 1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def IR(n): return([I() for _ in range(n)])
def S(): return(input())

def GCD(a,b):
    while(a%b != 0):
        a,b = b,a%b
    return b

def LCM(a,b):
    return a*b//GCD(a,b)

def main():
    N = I()
    A = IR(N)
    r = 0
    o = 0
    for a in A:
        if o==0:
            r += a//2
            o = a%2
        else:
            if a%2 == 1:
                r += (a+1)//2
                o = 0
            elif a>=2:
                r += a//2
                o = 1
            else:
                o = 0
    return r

if __name__ == "__main__":
    print(main())

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

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

Solution (Python):
def main():

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

    
    pairs = 0
    for i in range(N-1):
        pairs += A[i] // 2
        A[i] = A[i] % 2
        pairs += min(A[i], A[i+1])
        A[i], A[i+1] = A[i]-min(A[i], A[i+1]), A[i+1]-min(A[i], A[i+1])
    pairs += A[N-1] // 2

    return pairs

if __name__ == '__main__':
    print(main())

Solution (Python):
def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    ans = 0
    cur = 0
    for i in range(n):
        cur += a[i]
        if i == n-1 or a[i] == 0:
            ans += cur//2
            cur = 0
    print(ans)
if __name__ == "__main__":
    main()

Solution (Python):
def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    ans = 0
    for i in range(n):
        if a[i] == 0:
            continue
        ans += a[i]//2
        if i != n-1 and a[i]&1 and a[i+1] != 0:
            ans += 1
            a[i+1] -= 1
    print(ans)
if __name__ == "__main__":
    main()

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

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

def main():
    N = int(input())
    a = [int(input()) for i in range(N)]

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

if __name__ == "__main__":
    main()

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = [int(input().rstrip('\n')) for _ in range(n)]
    cnt = 0
    t = 0
    for v in a:
        if v == 0:
            cnt += (t // 2)
            t = 0
        else:
            t += v
    cnt += (t // 2)
    print(cnt)


if __name__ == '__main__':
    slove()

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

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

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

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

        c += a[i] // 2
        a[i] %= 2

print(c)

Solution (Python):
N=int(input())
l=[]

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

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

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

A = [0] * N
count = 0
for n in range(N):
    A[n] = int(input())

if all(A):
    print(sum(A) // 2)
    sys.exit()

index = 0
for n in range(N):
    if A[n] == 0:
        count += (sum(A[index: n]) // 2)
        index = n
count += sum(A[index:]) // 2
print(count)

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

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def A():

    return


def B():
    n = I()
    a = IR(n)
    ans = 0
    b = [0]*(n+1)
    for i in range(n):
        ans += (a[i]+b[i])>>1
        if (a[i]%2)^(b[i]%2) and a[i]:
            b[i+1] += 1
    print(ans)
    return


def C():

    return


def D():

    return


def E():

    return


def F():

    return


if __name__ == "__main__":
    B()

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

ans = 0
for i in range(N):
    p = a_list[i] // 2
    ans += p
    a_list[i] -= 2*p
    if i < N-1 and a_list[i] == 1 and a_list[i+1] > 0:
        a_list[i] -= 1
        a_list[i+1] -= 1
        ans += 1
print(ans)

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]
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 and i!=n-1 and a[i+1]>0:
        a[i+1]-=1
        ans+=1

print(ans)

Solution (Python):
N, *A = map(int, open(0).read().split())

ans = 0
pre = 0
for a in A:
    if a == 0:
        pre = 0
    else:
        q, pre = divmod(a + pre, 2)
        ans += q

print(ans)

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    N = int(input().rstrip('\n'))
    A = [int(input().rstrip('\n')) for _ in range(N)]
    t = 0
    cnt = 0
    for a in A:
        t += a
        if a == 0:
            cnt += (t // 2)
            t = 0
    cnt += (t // 2)
    print(cnt)


if __name__ == '__main__':
    slove()

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

Solution (Python):
n = int(input())
arr1 = [0 for i in range(n+1)]

partialsum = 0
ans = 0
for i in range(n):
    a = int(input())
    partialsum += a
    if a == 0:
        ans += partialsum//2
        partialsum = 0

ans += partialsum//2
print(ans)

Solution (Python):
N=int(input())
ans=0
_sum=0
for _ in range(N):
    A=int(input())
    _sum += A
    if A==0 or _==N-1:
        ans+=_sum//2
        _sum=0
print(ans)

Solution (Python):



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


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

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

Solution (Python):

import sys
input = sys.stdin.readline

def main():
    
    N = int(input())
    A = list(map(int, [input() for _ in range(N)])) + [0]
    ans, cur = 0, 0
    for i in A:
        if i:
            cur += i
        else:
            ans += cur // 2
            cur = 0
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, [input() for _ in range(N)])) + [0]
    ans = 0
    for i in range(N):  
        ans += A[i] // 2  
        if A[i] % 2 and A[i + 1]:  
            ans += 1
            A[i + 1] -= 1
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, [input() for _ in range(N)]))
    ans = 0
    for i in range(N - 1):  
        ans += A[i] // 2  
        if A[i] % 2 and A[i + 1]:  
            ans += 1
            A[i + 1] -= 1
    ans += A[-1] // 2  
    print(ans)


if __name__ == "__main__":
    main()