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 = [0]*n
res = 0
tmp = 0
zero = False
for i in range(n):
    s = int(input())
    a[i] = s
    if s==0:
        zero = True
if not zero:
    print(sum(a)//2)
    exit()

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

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

Solution (Python):
R=[0]
L=list()
N=int(input())
for i in range(N):
  k=int(input())
  L.append(k)
  if k==0:
    R.append(len(L))
S=sum(L)
R.append(N)
for i in range(len(R)-1):
  if sum(L[R[i]:R[i+1]])%2==1:
    S=S-1
print(S//2)

Solution (Python):
R = list()
L = list()
N = int(input())
R.append(0)
for i in range(N):
    k = int(input())
    L.append(k)
    if k == 0:
        R.append(len(L))
R.append(N)
S = sum(L)
for i in range(len(R) - 1):
    if sum(L[R[i] : R[i + 1]]) % 2 == 1:
        S = S - 1
print(S // 2)

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

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

print(ans)

Solution (Python):
def solve(N, A):
    ret = 0
    for idx in range(N):
        ret += A[idx] // 2
        A[idx] %= 2
        if A[idx] and idx + 1 < N and A[idx + 1]:
            ret += 1
            A[idx + 1] -= 1
    return ret

if __name__ == "__main__":
    N = int(input())
    A = [0 for _ in range(N)]
    for idx in range(N):
        A[idx] = int(input())
    print(solve(N, A))

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

cnt = 0
for i in range(n-1):
    cnt += a_list[i] // 2
    a_list[i] = a_list[i] % 2

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


cnt += a_list[n-1] // 2

print(cnt)

Solution (Python):
N = int(input())
ans = 0
tmp = 0
i = 0
while i < N:
  a = int(input())
  if a == 0:
    ans += tmp //2
    tmp = 0
  else:
    tmp += a
  i += 1
ans += tmp // 2
print(ans)

Solution (Python):
import sys
from collections import Counter
from collections import deque
import math
import bisect
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))


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

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

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

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

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

print(ans)

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

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

print(ans)

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

Solution (Python):
N=int(input())
A=[0]*N
for i in range(N):
    A[i]=int(input())
B   = [0]*N
B[0]= A[0] %2
ans= A[0]//2

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

print(ans)

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

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

print(ans)

Solution (Python):










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

"""
if N==1:
    print(A[0]//2)
else:
    for i in range(N-1):
        su=A[i]+A[i+1]
        cnt=cnt+su//2
        buf=(su//2)*2
        if buf>A[i]:
            A[i+1]=A[i+1]-(buf-A[i])
            A[i]=0
        else:
            A[i]=A[i]-buf
    
    print(cnt)
"""
su=0
for i in range(N):
    if A[i]!=0:
        su=su+A[i]
    else:
        cnt=cnt+su//2
        su=0
cnt=cnt+su//2
print(cnt)

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

if N==1:
    print(A[0]//2)
else:
    for i in range(N-1):
        su=A[i]+A[i+1]
        cnt=cnt+su//2
        buf=(su//2)*2
        if buf>A[i]:
            A[i+1]=A[i+1]-(buf-A[i])
            A[i]=0
        else:
            A[i]=A[i]-buf
    
    print(cnt)

Solution (Python):
n = int(input())
ans = 0
li = []
tmp = 0
for i in range(n):
    t = int(input())
    if t == 0:
        li.append(tmp)
        tmp = 0
    else:
        tmp += t
li.append(tmp)
for l in li:
    ans += l//2

print(ans)

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

ans = 0

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

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

temp=0
cnt=0


for _ in range(n):
    a=int(input())
    hoge=min(a,temp)
    cnt+=hoge

    if a>hoge:
        cnt+=(a-hoge)//2
        temp=(a-hoge)-((a-hoge)//2)*2
    else:
        temp=0

print(cnt)

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

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

n = 0
ans = 0
for i in range(N):
    if A[i]:
        n += A[i]
    else:
        ans += n//2
        n = 0
ans += n//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
    a[i]=a[i]%2
    if i<n-1 and a[i]>0 and a[i+1]>0:
        a[i]=0
        a[i+1]-=1
        ans+=1
print(ans)

Solution (Python):
import sys

N = int(sys.stdin.readline().rstrip())

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

pairs = 0
res = 0
for a_i in A:
    if a_i == 0:
        res = 0
        continue
    
    a_i += res
    r = a_i // 2
    pairs += r
    res = a_i - 2*r

print(pairs)

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

total = 0

remain = 0
c = 0
for i in range(n):
    m = int(input())
    if i > c + 1:
        remain = 0
    all_ = remain + m
    total += all_//2
    if all_ % 2 != 0 and all_//2 > 0:
        remain = all_ % 2
        c = i
print(total)

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

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

print(cnt)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = [0] + list(int(input()) for _ in range(n)) + [0]

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

    print(res)


if __name__ == '__main__':
    resolve()

Solution (Python):
from itertools import*
_, *a = map(int, open(0))
print(sum(sum(l)//2 for _, l in groupby(a, key=lambda x:x>0)))

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

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

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

if n == 1:
    print(al[0] // 2 * 2 // 2)
    exit()
ans = 0
for i in range(n-1):
    rest = ((al[i] + al[i+1]) // 2) * 2
    ans += rest
    for j in range(2):
        if al[i+j] >= rest:
            al[i+j] -= rest
            break
        else:
            rest -= al[i+j]
            al[i+j] = 0


print(ans//2)

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
lst1 = []
for i in range(n):
    lst1.append(int(readline()))

ans = 0
lst2 = []
for i in lst1:
    i -= 2
    if i >= 0:
        ans += (i+1)//2
    if i == -2:
        lst2.append(0)
    elif even(i):
        lst2.append(2)
    else:
        lst2.append(1)

now = 0
while now < n:
    if now == 0:
        if lst2[now] == 2:
            ans += 1
            lst2[now] = 0
        now += 1
        continue
    if lst2[now-1] == 1 and lst2[now] == 2:
        ans += 1
        lst2[now] = 1
        now += 1
        continue

    if lst2[now-1] == 1 and lst2[now] == 1:
        ans += 1
        lst2[now] = 0
        now += 1
        continue
    
    if lst2[now] == 2:
        ans += 1
        lst2[now] = 0
        now += 1
        continue
    now += 1

print(ans)

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

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

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

ans = 0
nokori = 0

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

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

print(ans)

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

ans = 0
nokori = 0

for i in range(n):
    if ai[i] % 2 == 1:
        if nokori == 1:
            nokori = 0
            ans += ai[i] // 2 + 1
        else:
            nokori = 1
            ans += ai[i] // 2
    elif ai[i] > 0:
        if nokori == 1:
            ans += ai[i] // 2
            nokori = 1
        else:
            ans += ai[i] // 2
            nokori = 0
    elif ai[i] == 0:
        nokori = 0

print(ans)

Solution (Python):
n = int(input())
a = []

for i in range(n):
    a.append(int(input()))

b = []
chain = 0
for i in range(n):
    if(chain>=1 and a[i]==0):
        b.append(chain)
        chain = 0
    elif(a[i]>=1):
        chain += a[i]
ans=0
b.append(chain)
for i in b:
    ans += i//2
    
print(ans)

Solution (Python):
n = int(input())
a = []
from collections import Counter
for _ in range(n):
    a.append(int(input()))
    
a = a + [0]
    
ans = 0
for i in range(n):
    ans += a[i] // 2
    a[i] %= 2
    if a[i] == 1 and a[i+1] >= 1:
        ans += 1
        a[i] = 0
        a[i+1] -= 1
        
print(ans)

Solution (Python):
n = int(input())
a = []
from collections import Counter
for _ in range(n):
    a.append(int(input()))
a = [0] + a
    
cursum = 0
ans = 0
for i in range(1,n+1):
    if a[i] == 0:
        ans += cursum // 2
        cursum = 0
    else:
        cursum += a[i]
        
ans += cursum // 2
print(ans)

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

def f(lst):
  res = 0
  ex = 0
  for a in lst:
    ex += a
    res += ex//2
    ex %= 2
  return res

A = []
ans = 0
for _ in range(n):
  a = int(input())
  if a%2:
    ans += a//2
    a = 1
  else:
    if a>2:
      ans += a//2-1
      a = 2

  if a!= 0:
    A.append(a)
  elif A:
    ans += max(f(A), f(A[::-1]))
    A = []
  else:
    continue
else:
  ans += max(f(A), f(A[::-1]))
print(ans)

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

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

Solution (Python):
import sys
import math  
import bisect  
import queue  


def input():
    return sys.stdin.readline().rstrip()


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

    B = []
    C = []
    for a in A:
        if a != 0:
            C.append(a)
        else:
            B.append(C)
            C = []
    if len(C) > 0:
        B.append(C)

    res = 0
    for b in B:
        res += sum(b) // 2
    print(res)


if __name__ == '__main__':
    main()

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

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

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

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

print(ans)

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

print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 5 + 10)


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


def resolve():
    n = int(input())
    A = [int(input()) for i in range(n)]

    ans = 0
    seq_cnt = 0
    for i in range(n):
        if A[i] != 0:
            seq_cnt += A[i]
        else:
            ans += seq_cnt // 2
            seq_cnt = 0
    ans += seq_cnt // 2

    print(ans)


resolve()

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

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

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

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

print(cnt)

Solution (Python):
N, *A = map(int, open(0).read().split())
ls = []
s = 0
ans = 0
for c in A:
  if c==0:
    ans += s//2
    s = 0
  else:
    s += c
ans += s//2
print(ans)

Solution (Python):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
a = nin(n)

ans = 0
cnt = 0
for i in range(n):
    if a[i] != 0:
        cnt += a[i]
    else:
        ans += cnt // 2
        cnt = 0
ans += cnt // 2

print(ans)

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

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

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

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

ans=0
if N==1:
    print(A[0]//2)
    exit()

for i in range(N):
    if i==(N-1):
        ans+=A[i]//2
        break
    if i==0:
        ans+=A[i]//2
        ans+=min(A[i]%2,A[i+1])
        A[i+1]=max(0,A[i+1]-A[i]%2)
        continue
    ans+=A[i]//2
    ans+=min(A[i]%2,A[i+1])
    A[i+1]=max(0,A[i+1]-A[i]%2)
print(ans)

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
A = []
for i in range(N):
    A.append(int(input()))
    
ans = 0
for i in range(N-1):
    ans += (A[i]//2)
    A[i+1] -= min(A[i+1],A[i]%2)
    ans += min(A[i+1],A[i]%2)
ans += (A[-1]//2)
print(ans)

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

current_partition_cnt = 0
ans = 0
for a in An:
    if a == 0:
        ans += current_partition_cnt//2
        current_partition_cnt = 0
    else:
        current_partition_cnt += a
ans += current_partition_cnt//2
print(ans)

Solution (Python):
def solve():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    ans = 0
    for a in A:
        ans += a//2
    prev = 0
    for a in A:
        new = a%2
        if prev == 1:
            if new == 1:
                ans += 1
            elif a>0:
                prev = 1
            else:
                prev = 0
        prev = prev^new
    return ans
print(solve())

Solution (Python):
import sys

n, *aaa = map(int, sys.stdin.buffer.read().split())

ans = 0
for i in range(n - 1):
    d, m = divmod(aaa[i], 2)
    ans += d
    if m and aaa[i + 1]:
        aaa[i + 1] -= 1
        ans += 1
ans += aaa[-1] // 2
print(ans)

Solution (Python):




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

ans = 0
temp = 0
for m in nums:
    if m == 0:
        ans += temp // 2
        temp = 0
    else:
        temp += m
ans += temp // 2
print(ans)

Solution (Python):



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

ans = 0
for idx, m in enumerate(nums):
    if m > 0:
        ans += m // 2
        
        m = m & 1
    if m == 1 and idx != n-1 and nums[idx+1] >= 1:
        ans += 1
        m -= 1
        nums[idx+1] -= 1

print(ans)

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


def counter(ar):
    count = 0
    for i in range(N):
        
        if i > 0:
            c = min(ar[i - 1], ar[i])
            ar[i - 1] -= c
            ar[i] -= c
            count += c
        c = ar[i] // 2
        ar[i] -= c * 2
        count += c
        if i < N - 1:
            c = min(ar[i], ar[i + 1])
            ar[i] -= c
            ar[i + 1] -= c
            count += c
    return count





AA1 = A[:]
c1 = counter(AA1)
AA2 = A[::-1]
c2 = counter(AA2)


print(max(c1, c2))

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

ans = 0
rest = 0
for i, a in enumerate(A):
    if rest == 0:
        ans += a // 2
        rest = a % 2
    else:
        if (a + rest) % 2 == 0:
            ans += (a + rest) // 2
            rest = 0
        else:
            ans += (rest + a) // 2
            rest = 1 if a != 0 else 0

print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = [int(readline()) for i in range(n)][::-1]
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[-1] // 2
print(ans)

Solution (Python):
from sys import stdin
def main():
    N = int(stdin.readline())
    ans = c = 0
    for _ in range(N):
        a = int(stdin.readline())
        if a:
            c += a
        else:
            ans += c >> 1
            c = 0
    print(ans + (c >> 1))
if __name__ == "__main__":
    main()

Solution (Python):
import sys
N = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(N)]
ans = 0
for i in range(1, N):
    ans += (A[i - 1] + A[i]) >> 1
    if A[i]:
        A[i] = (A[i - 1] + A[i]) & 1
print(A[0] >> 1 if N == 1 else ans)

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

Solution (Python):
n = int(input())
ans = 0
flow = 0
for i in range(n):
  a = int(input())
  if a == 0:
    flow = 0
  else :
    ans += (a + flow) // 2
    flow = (a + flow) % 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+1]:
        a[i+1]+=a[i]%2
ans+=a[-1]//2
print(ans)

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def isOK(S):
    visited = [[False for _ in range(10)]for _ in range(10)]
    sx, sy = 0, 0
    for y in range(10):
        for x in range(10):
            if S[y][x] == 'o':
                sx = x
                sy = y
                break
    q = []
    q.append((sx, sy))
    while q != []:
        x, y = q.pop()
        visited[y][x] = True
        DIR = [(-1, 0), (1, 0), (0, -1), (0, 1)]
        for d in DIR:
            nx, ny = x + d[0], y + d[1]
            if not 0 <= nx < 10:
                continue
            if not 0 <= ny < 10:
                continue
            if visited[ny][nx]:
                continue
            if S[ny][nx] == 'x':
                continue
            q.append((nx, ny))
    for y in range(10):
        for x in range(10):
            if not visited[y][x] and S[y][x] == 'o':
                return False
    return True


def solve():
    N = Scanner.int()
    ans = 0
    tmp = 0
    for _ in range(N):
        A = Scanner.int()
        if A == 0:
            ans += tmp // 2
            tmp = 0
        else:
            tmp += A
    ans += tmp // 2
    print(ans)


def main():
    
    solve()


if __name__ == "__main__":
    main()

Solution (Python):

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

print(cnt)

Solution (Python):


enu = enumerate
ra = range
N, *A = map(int, open(0).read().split())
ans = 0



'''
反例
1...1
2...2
3...1のとき、2同士で先にペアを作る前に上と下に配ったほうがいい
'''



stock = 0  
for a in A:
    if a == 0:
        stock = 0
        continue
    a += stock
    ans += a // 2
    stock = a & 1  

print(ans)

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

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

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


print(sum(main()))

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

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

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

    yield x // 2


print(sum(main()))

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

Solution (Python):
import numpy as np
N = int(input())
A = np.array([int(input()) for _ in range(N)])
ans = 0
for i in range(N-1):
    d,m = divmod(A[i],2)
    ans += d
    if m == 1:
        if A[i+1] > 0:
            A[i+1] -= 1
            ans += 1

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

Solution (Python):
mod = 10 ** 9 + 7
mod2 = 2 ** 61 + 1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

_NUMINT_ALL = list(range(10))


def main():
    ans = solve()

    if ans in [True, False]:
        YesNo(ans)
    elif ans is not None:
        print(ans)


def solve():
    N = iip(False)
    A = iipt(N)

    cur = 0
    ans = 0
    for i in A:
        if cur == 1 and i>=1:
            ans += 1
            i -= 1

        ans += i//2
        cur = i%2


    print(ans)






def iip(listed=True, num_only=True):  
    if num_only:
        ret = [int(i) for i in input().split()]
    else:
        ret = [int(i) if i in _NUMINT_ALL else i for i in input().split()]

    if len(ret) == 1 and not listed:
        return ret[0]
    return ret


def saidai_kouyakusuu(A):  
    l = len(A)
    while True:
        m = min(A)
        mx = max(A)
        if m == mx:
            return m

        for i in range(l):
            if A[i] % m == 0:
                A[i] = m
            else:
                A[i] %= m


def sort_tuples(l, index):  
    if isinstance(l, list):
        l.sort(key=lambda x: x[index])
        return l
    else:
        l = list(l)
        return sorted(l, key=lambda x: x[index])


def count_elements(l):  
    d = {}
    for i in l:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    return d


def safeget(l, index, default="exception"):  
    if index >= len(l):                      
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。配列の長さは", len(l), "です"]))
        else:
            return default
    elif index < 0:
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。負の値は許可されていません"]))
        else:
            return default
    else:
        return l[index]


def iipt(l, listed=False, num_only=True):  
    ret = []
    for i in range(l):
        ret.append(iip(listed=listed, num_only=num_only))
    return ret


def sortstr(s):  
    return "".join(sorted(s))


def iip_ord(startcode="a"):  
    if isinstance(startcode, str):
        startcode = ord(startcode)
    return [ord(i) - startcode for i in input()]


def YesNo(s):  
    if s:
        print("Yes")
    else:
        print("No")


def fprint(s):  
    for i in s:
        print(i)


def bitall(N):  
    ret = []
    for i in range(2 ** N):
        a = []
        for j in range(N):
            a.append(i % 2)
            i //= 2
        ret.append(a)
    return ret

def split_print_space(s):  
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):  
    print("\n".join([str(i) for i in s]))


def soinsuu_bunkai(n):  
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):  
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        
        pass
    return ret


def inv(n, mod):  
    return power(n, mod - 2)


def power(n, p, mod_=mod):  
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


if __name__ == "__main__":
    main()