Harryxun/stf_run huggingface dataset:
n = int(input())

if n%2 != 0:
  print(0)
else:
  ans = 0
  while n > 0:
    n //= 5
    ans += n//2
print(ans)
  

### FIXED CODE ###

n = int(input())
base = 10
ans = 0
 
if n%2 == 1:
  print(0)
else:
  for i in range(1,100):
    ans += n//base    
    base *= 5   
  print(ans)
s = list(input())
k = int(input())

if s[0] == '1' and len(s) == 1:
  print(s[0])
if s[0] == '1' and s[:k] == ['1']*k:
  print(s[1])
elif s[0]!='1':
  print(s[0])

### FIXED CODE ###

s = list(input())
k = int(input())

if s[0] == '1' and len(s) == 1:
  print(1)
  exit()
elif s[0] != '1':
  print(s[0])
  exit()

if k > 100:
  for i in s:
    if i != '1':
      print(i)
      exit()
  print(1)
  
else:
  for i in s[:k]:
    if i != '1':
      print(i)
      exit()
  print(1)
  exit()
N=int(input())
A=[list(map(int,list(input()))) for i in range(N)]

s=1
for i in range(N):
    s = s*A[i]
    if s > 10**18:
        s = -1
        print('-1')
        break
if s != -1:
    print(s)

### FIXED CODE ###

N=int(input())
A=list(map(int, input().split()))

s=1
if min(A) == 0:
    s = 0
    print(s)
elif max(A) > 10**18:
    s = -1
    print(s)
else:
    for i in range(N):
        s = s*A[i]
        if s > 10**18:
            s = -1
            print('-1')
            break
    if s != -1:
        print(s)
from numba import njit, jit, int32
import numpy as np
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
# p = list(map(int, input().split()))
p = np.array(input().split(), dtype=np.int32)


@njit('(i4,i4[::1])', cache=True)
def main(n, p):
#     d = [[None]*n for _ in range(n)]
    d = np.zeros((n,n), dtype=np.int32)
    for i in range(n):
        for j in range(n):
            d[i,j] = min(i, n-1-i, j, n-1-j)
#     vacant = [[False]*n for _ in range(n)]
    vacant = np.zeros((n,n), dtype=np.int32)

    ans = 0
    for v in p:
        v -= 1
        x,y = v//n, v%n
        ans += d[x,y]
    #     print(v, d[x][y], d)
        v = d[x,y]
        q = [(v, x, y)]
        dx = [0,1,0,-1]
        dy = [1,0,-1,0]
        while q:
            v,i,j = q.pop()
            for xx, yy in zip(dx,dy):
                ii = i+xx
                jj = j+yy
                if ii<0 or jj<0 or ii>=n or jj>=n:
                    continue
                if d[ii,jj]>v:
                    d[ii,jj] = v
                    nv = v+1 if not vacant[ii,jj] else v
                    q.append((nv, ii, jj))

        vacant[x,y] = 1
    return ans
ans = main(n,p)
print(ans)

### FIXED CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
p = list(map(int, input().split()))

d = [None] * (n**2)
for i in range(n):
    for j in range(n):
        d[i*n+j] = min(i, n-1-i, j, n-1-j)
vacant = [False] * (n**2)

ans = 0
for pos in p:
    pos -= 1
    ans += d[pos]
    vacant[pos] = True
    q = [pos]
    while q:
        pos = q.pop()
        tmp = not vacant[pos]
#         for diff in (-1, 1, -n, n):
#             ppos = diff+pos
#             if ppos<0 or ppos>=n*n:
#                 continue
#             if d[ppos]>d[pos]+tmp:
#                 d[ppos] = d[pos] + tmp
#                 q.append(ppos)
        if pos+n<n*n:
            ppos = pos + n
            if d[ppos]>d[pos]+tmp:
                d[ppos] = d[pos] + tmp
                q.append(ppos)
        if pos-n>=0:
            ppos = pos - n
            if d[ppos]>d[pos]+tmp:
                d[ppos] = d[pos] + tmp
                q.append(ppos)
        if pos+1<n*n:
            ppos = pos + 1
            if d[ppos]>d[pos]+tmp:
                d[ppos] = d[pos] + tmp
                q.append(ppos)
        if pos-1>=0:
            ppos = pos - 1
            if d[ppos]>d[pos]+tmp:
                d[ppos] = d[pos] + tmp
                q.append(ppos)
print(ans)
N = int(input())
Mylist = list(input())
ANSlist = []
if N%2 == 1:
  print("No")
else: 
  for i in range(N/2):
    if Mylist[i] == Mylist[i + N/2]:
      ANSlist.append("Yes")
  if len(ANSlist) == N/2:
    print("Yes")

### FIXED CODE ###

N = int(input())
Mylist = list(input())
ANSlist = []
if N%2 == 1:
  print("No")
else: 
    for i in range(int(N/2)):
        if Mylist[i] == Mylist[i + int(N/2)]:
            ANSlist.append("Yes")
    if len(ANSlist) == N/2:
        print("Yes")
    else:
        print("No")
d = {"Sunny": "Cloudy", "Cloudy": "Rainy", "Rainy": "Sunny"}
print(d[s])

### FIXED CODE ###

s = input()
d = {"Sunny": "Cloudy", "Cloudy": "Rainy", "Rainy": "Sunny"}
print(d[s])
from itertools import accumulate
from bisect import bisect_left, bisect_right
n = int(input())
a = list(map(int, input().split()))

sum_par = 0
cur, prv = 0, 0
sum_a = sum(a)
mid = sum_a//2
cost = 0
if sum_a%2 != 0:
    cost += 1
    mid += 1
for i in range(n):
    cur += a[i]
    if abs(cur-mid) > abs(prv-mid):
        obj = prv
        break
    prv = cur

cost += abs(obj-mid)*2
print(cost)

### FIXED CODE ###

from itertools import accumulate

n = int(input())
a = list(map(int, input().split()))

sum_l = [0]+list(accumulate(a))
sum_r = [0]+list(accumulate(a[-1::-1]))

cost = sum_r[-1]
for i in range(n+1):
    cost = min(cost, abs(sum_l[i]-sum_r[n-i]))
print(cost)
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
re = [0] * (n-1)

c = Counter(a)   # c: Counter({1: 3, 2: 2})など
for k, v in c.items():
    re[k] = v*(v-1) // 2

total = sum(re)
for i in a:
    print(total - re[i] + (c[i]-1)*(c[i]-2) // 2)

### FIXED CODE ###

from collections import Counter

n = int(input())
a = list(map(int, input().split()))
re = [0] * (n+1)

c = Counter(a)   # c: Counter({1: 3, 2: 2})など
for k, v in c.items():
    re[k] = v*(v-1) // 2

total = sum(re)
for i in a:
    print(total - re[i] + (c[i]-1)*(c[i]-2) // 2)
while C > 0 and A > 0:
    C -= B
    A -= D
    if C <= 0:
        print("Yes")
    elif A <= 0:
        print("No")
    else:
        pass

### FIXED CODE ###

A,B,C,D = map(int,input().split())

while C > 0 and A > 0:
    C -= B
    A -= D
    if C <= 0:
        print("Yes")
    elif A <= 0:
        print("No")
    else:
        pass
import fractions
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
def gcd(*numbers):
    return reduce(gcd, numbers)
def gcd_list(numbers):
    return reduce(gcd, numbers)
print(gcd_list(a))

### FIXED CODE ###

import fractions
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
print(reduce(fractions.gcd,a))
cnt = int(input())
li = list(map(int,input().split()))
re_li = li[::-1]
print(' '.join(map(str,re_li)


### FIXED CODE ###

cnt = int(input())
li = list(map(int,input().split()))
re_li = li[::-1]
print(' '.join(map(str,re_li)))
from collections import defaultdict
from numba import njit, b1, i4, i8, f8

@njit(cache = True)
def get_prime_factors(x):
    return [2, 3]

@njit
def main():
    df = defaultdict(lambda : 0)
    
    
    for ai in a:
        primes = get_prime_factors(ai)
        for prime in primes:
            df[prime] += 1
    if df.values():
        val = max(df.values())
        if val == 1:
            print("pairwise coprime")
        elif val == n:
            print("not coprime")
        else:
            print("setwise coprime")
    else:
        print("pairwise coprime")

n = int(input())
a = list(map(int, input().split()))
main()


### FIXED CODE ###

from collections import defaultdict


def get_prime_factors(x):
    out = set()
    if x < 1:
        return out
    while not x%2:
        out.add(2)
        x //= 2
    i = 3
    while i*i <= x:
        if not x%i:
            out.add(i)
            x //= i
        else:
            i += 2
    if x != 1:
        out.add(x)
    return out


def main():
    n = int(input())
    a = list(map(int, input().split()))
    df = defaultdict(lambda : 0)
    for ai in a:
        primes = get_prime_factors(ai)
        for prime in primes:
            df[prime] += 1
    if df.values():
        val = max(df.values())
        if val == 1:
            print("pairwise coprime")
        elif val == n:
            print("not coprime")
        else:
            print("setwise coprime")
    else:
        print("pairwise coprime")

if __name__ == "__main__":
    main()
import math
print(2**(math.ceil(log(input(H),2)))-1)

### FIXED CODE ###

import math
print(2**(math.ceil(math.log2(float(input())+1)))-1)
A, B, C = map(int, input().split())

if any([A % 2, B % 2, C % 2]):
	print(0)
	exit()

if A == B == C:
	print(-1)
	exit()

count = 0
    while all([A % 2 == 0, B % 2 == 0, C % 2 == 0]):
        A, B, C = ((B+C)//2, (A+C)//2, (A+B)//2)
	count += 1
print(count)


### FIXED CODE ###

A, B, C = map(int, input().split())

if any([A % 2, B % 2, C % 2]):
	print(0)
	exit()

if A == B == C:
	print(-1)
	exit()

count = 0
while True:
	if any([A % 2, B % 2, C % 2]):
		break
	A, B, C = B // 2 + C // 2, A // 2 + C // 2, A // 2 + B // 2
	count += 1
print(count)
S = str(input())

circles = 0
crosses = 0

for i in S:
    if S = 'o':
        circles += 1
    else:
        crosses += 1
if circles >= 8:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

S = str(input())

circles = 0
crosses = 0

length = len(S)
rest = 15 - length


for i in S:
    if i == 'o':
        circles += 1
    else:
        crosses += 1

if rest + circles >= 8:
    print('YES')
else:
    print('NO')
n = int(input())
ls = list(map(int,input().split()))
a = min(ls)
b = max(ls)
c = len(ls)
s = 0
def sub(p,q):
    return p-q
ans = []
aaa = [0]*(b-a+1)
for i in range(a,b+1):
    new = [i]*(c)
    ans = map(sub,ls,new)
    ans = list(map(str,ans))
    s = ans.count("-1") + ans.count("1") + ans.count("0")
    aaa[i-1] = s
print(aaa)
print(max(aaa))

### FIXED CODE ###

n = int(input())
ls = list(map(int,input().split()))
di = [0]*(max(ls)+3)
for i in ls:
    di[i] += 1
    di[i+1] += 1
    di[i+2] += 1
print(max(di))
n = input()
print(10 - n // 200)

### FIXED CODE ###

n = int(input())
print(10 - n // 200)
import itertools
H, W = [int(_) for _ in input().split()]
S = [input() for _ in range(H)]
A = [[0 for _ in range(W)] for _ in range(H)]
count = {}


def bfs(x, y, p, q):
    if A[x][y] == 1:
        return
    else:
        A[x][y] = 1
        count[p * H + q] = count.get(p * H + q, {})
        count[p * H + q]['#'] = count[p * H + q].get('#', 0)
        count[p * H + q]['.'] = count[p * H + q].get('.', 0)
        count[p * H + q][S[x][y]] += 1
        dxy = [[-1, 0], [1, 0], [0, -1], [0, 1]]
        for dx, dy in dxy:
            nx, ny = x + dx, y + dy
            if 0 <= nx < H and 0 <= ny < W:
                if S[x][y] != S[nx][ny] and A[nx][ny] == 0:
                    bfs(nx, ny, p, q)


for i, j in itertools.product(range(H), range(W)):
    bfs(i, j, i, j)
ans = 0
if count:
    for i in count:
        ans += count[i].get('#', 0) * count[i].get('.', 0)
print(ans)


### FIXED CODE ###

import itertools
H, W = [int(_) for _ in input().split()]
S = [input() for _ in range(H)]
A = [[0 for _ in range(W)] for _ in range(H)]


def dfs(p, q):
    if A[p][q] == 1:
        return 0
    count = {'#': 0, '.': 0}
    stack = [[p, q]]
    while stack:
        x, y = stack.pop()
        if A[x][y] != 1:
            count[S[x][y]] += 1
            A[x][y] = 1
            dxy = [[-1, 0], [1, 0], [0, -1], [0, 1]]
            for dx, dy in dxy:
                nx, ny = x + dx, y + dy
                if 0 <= nx < H and 0 <= ny < W and S[x][y] != S[nx][ny]:
                    stack += [[nx, ny]]
    return count['#'] * count['.']


print(sum([dfs(i, j) for i, j in itertools.product(range(H), range(W))]))
import math
a, b, x = [int(x) for x in input().split()]
y = 2 * (b - (x / (a * a)))
if y <= b:
    value = a / y
    print(90 - math.degrees(math.atan(value)))
else:
    y = (2 * x) / (a * b)
    v = b / y
    print(math.degrees(math.atan(v)))

### FIXED CODE ###

import math
a, b, x = [int(x) for x in input().split()]
y = 2 * (b - (x / (a * a)))
if x == a * a * b: print(0)
elif y <= b:
    value = a / y
    print(90 - math.degrees(math.atan(value)))
else:
    y = (2 * x) / (a * b)
    v = b / y
    print(math.degrees(math.atan(v)))
import collections
I = [int(_) for _ in open(0).read().split()]
N = I[0]
AB = I[1:]
G = collections.defaultdict(set)
for a, b in zip(AB[::2], AB[1::2]):
    G[a].add(b)
    G[b].add(a)
color = [None] * (N + 1)


def dfs(G, v, cur):
    color[v] = cur
    for w in G[v]:
        if color[w] is None:
            dfs(G, w, 1 - cur)


dfs(G, 1, 0)
c=collections.Counter(color[1:])

### FIXED CODE ###

import collections
import sys
sys.setrecursionlimit(2*10**5)
I = [int(_) for _ in open(0).read().split()]
N = I[0]
AB = I[1:]
G = collections.defaultdict(set)
for a, b in zip(AB[::2], AB[1::2]):
    G[a].add(b)
    G[b].add(a)
color = [None] * (N + 1)


def dfs(G, v, cur):
    color[v] = cur
    for w in G[v]:
        if color[w] is None:
            dfs(G, w, 1 - cur)


dfs(G, 1, 0)
c=collections.Counter(color[1:])
cand1 = set(range(1, N + 1, 3))
cand2 = set(range(2, N + 1, 3))
cand3 = set(range(3, N + 1, 3))

i0, i1 = 0, 1
if c[0] > c[1]:
    i0, i1 = 1, 0

ans = [None] * (N + 1)
if c[i0] <= len(cand3):
    for i in range(1, N + 1):
        if color[i]==i0:
            ans[i] = cand3.pop()
        else:
            if cand1:
                ans[i] = cand1.pop()
            elif cand2:
                ans[i] = cand2.pop()
            elif cand3:
                ans[i] = cand3.pop()
else:
    for i in range(1, N + 1):
        if color[i] == i0:
            if cand2:
                ans[i] = cand2.pop()
            elif cand3:
                ans[i] = cand3.pop()
        else:
            if cand1:
                ans[i] = cand1.pop()
            elif cand3:
                ans[i] = cand3.pop()
print(*ans[1:])
s = list(input())
t = list(input())
s = s.sort()
t = t.sort()
t = t.reverse()
s = ''.join(s)
t = ''.join(t)
if s < t:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

s = list(input())
t = list(input())
s.sort()
t.sort()
t.reverse()
s = ''.join(s)
t = ''.join(t)
if s < t:
  print('Yes')
else:
  print('No')
import sys
input=sys.stdin.readline
N=int(input())
S=list(input()[:-1])
c=0
for i in range(1,N+1):
  if S[i-1]=='#'and S[i]=='.':
    S[i]='#'
    c+=1
print(c)

### FIXED CODE ###

import sys
input=sys.stdin.readline
N=int(input())
S=input()
w=S.count('.')
c=w
for i in range(N):
  if S[i]=='.':
    w-=1
  else:
    w+=1
  c=min(c,w)
print(c)
N=int(input())
A={}
for i in range(1,N+1):
    A[i]=int(input())
A=sorted(A.items(),key=lambda x:x[1])
for k in A:
    print(k[0],end=" ")

### FIXED CODE ###

N=int(input())
A=map(int,input().split())
A=list(A)
B={}
for i in range(1,N+1):
    B[i]=A[i-1]

B=sorted(B.items(),key=lambda x:x[1])
for k in B:
    print(k[0],end=" ")
t=input()
result=''
for i in range(len(t)):
    if t[i]=='?':
        if result[i-1]=='P'or t[i+1]=='P':
            result+='D'
        else:
            result+='P'
    else:
        result+=t[i]
print(result)

### FIXED CODE ###

t=input()
result=''
for i in range(len(t)-1):
    if t[i]=='?':
        try:
            if result[i-1]=='P':
                result+='D'
            else:
                if t[i+1]=='P':
                    result+='D'
                else:
                    result+='P'
        except:
            if t[i+1]=='P':
                result+='D'
            else:
                result+='P'
    else:
        result+=t[i]
if t[len(t)-1]=='?' or  t[len(t)-1]=='D':
    print(result+'D')
else:
    print(result+'P')
# abc163B
# https://atcoder.jp/contests/abc163/tasks/abc163_b

# 夏休みはN日間
# 夏休みの宿題はM個
# 宿題は同じ日に複数できない、宿題の時は遊ぶことはできない
# 最大何日間遊ぶことが出来るか
# 夏休み中に終わらせられない場合は、"-1"

# 入力
n = int(input())
m = int(input())
a = list(map(int, input().split()))

# 処理
answer = n - sum(a)

if answer > 0:
    print(answer)
else:
    print("-1")


### FIXED CODE ###

# abc163B
# https://atcoder.jp/contests/abc163/tasks/abc163_b

# 夏休みはN日間
# 夏休みの宿題はM個
# 宿題は同じ日に複数できない、宿題の時は遊ぶことはできない
# 最大何日間遊ぶことが出来るか
# 夏休み中に終わらせられない場合は、"-1"

# 入力
n, m = map(int, input().split())
a = list(map(int, input().split()))

# 処理
# 宿題にかかる合計日数
answer = n - sum(a)

if answer < 0:
    print("-1")
else:
    print(answer)
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
sousa = sorted([[int(i) for i in input().split()] for i in range(M)], reverse=True, key=lambda x:x[1])
for cnt, value in sousa:
    for i in range(cnt):
        if min(A) < value:
            A[A.index(min(A))] = value
        else:
            return(sum(A))
return(sum(A))

### FIXED CODE ###

def check():
    N, M = map(int, input().split())
    A = sorted([int(i) for i in input().split()])
    sousa = sorted([[int(i) for i in input().split()] for i in range(M)],
                   reverse=True, key=lambda x:x[1])
    index = 0
    for cnt, value in sousa:
        for i in range(cnt):
            if index == N:
                break
            if A[index] < value:
                A[index] = value
            else:
                return(sum(A))
            index += 1
    return(sum(A))
print(check())
n, m, q = map(int, input().split())
train = [tuple(map(int, input().split())) for _ in range(m)]
quest = [tuple(map(int, input().split())) for _ in range(q)]
dp = [[0 for _ in range(n)] for _ in range(n)]
d = {}
for l in range(n):
    for r in range(l,n):
        d[(l,r)] = 0
for p, q in train:
    else:
        d[(p,q)] += 1
for l in range(n):
    dp[l][l] = d[(l+1,l+1)]
for w in range(1,n):
    for l in range(n-w):
        dp[l][l+w] = dp[l][l+w-1] + d[(l,l+w)]
for l, r in quest:
    print(dp[l-1][r-1])


### FIXED CODE ###

n, m, q = map(int, input().split())
train = [tuple(map(int, input().split())) for _ in range(m)]
quest = [tuple(map(int, input().split())) for _ in range(q)]
dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
d = {}
for l in range(n):
    for r in range(l,n):
        d[(l+1,r+1)] = 0
for p, q in train:
    d[(p,q)] += 1
for l in range(1,n+1):
    dp[l][l] = d[(l,l)]
for w in range(1,n):
    for l in range(n-w):
        dp[l+1][l+w+1] = dp[l+1][l+w] + dp[l+2][l+w+1] - dp[l+2][l+w] + d[(l+1,l+w+1)]
for l, r in quest:
    print(dp[l][r])
N = int(input())
M = 9
L = 2*M
A = [[0 for _ in range(L+1)] for _ in range(L+1)]

for _ in range(N):
  y = float(input())
  x = y
  x *= 10.**M
  x = int(x)
  k_2 = 0
  while x % 2 == 0 and k_2 <= 2*M:
    x = x // 2
    k_2 += 1
  k_5 = 0 
  while x % 5 == 0 and k_5 <= 2*M:
    x = x // 5
    k_5 += 1
  A[k_2][k_5] += 1

ans = 0
for k_2 in range(L+1):
  for k_5 in range(L+1):
    for l_2 in range(k_2, L+1):
      for l_5 in range(L+1):
        if k_2+l_2 >= 2*M and k_5+l_5 >= 2*M:
          if k_2 == l_2 and k_5 == l_5:
            ans += A[k_2][k_5]*(A[k_2][k_5]-1)//2
            
          elif l_2 > k_2 or (k_2 == l_2 and k_5 < l_5):
            ans += A[k_2][k_5]*A[l_2][l_5]
          
#print(A)
print(ans)

### FIXED CODE ###

N = int(input())
M = 10
L = 2*M
A = [[0 for _ in range(L+1)] for _ in range(L+1)]

for _ in range(N):
  y = float(input())
  x = y
  x *= 10.**M
  x = int(x+0.1)
  k_2 = 0
  while x % 2 == 0 and k_2 < 2*M:
    x = x // 2
    k_2 += 1
  k_5 = 0 
  while x % 5 == 0 and k_5 < 2*M:
    x = x // 5
    k_5 += 1
  A[k_2][k_5] += 1

ans = 0
for k_2 in range(L+1):
  for k_5 in range(L+1):
    for l_2 in range(k_2, L+1):
      for l_5 in range(L+1):
        if k_2+l_2 >= 2*M and k_5+l_5 >= 2*M:
          if k_2 == l_2 and k_5 == l_5:
            ans += A[k_2][k_5]*(A[k_2][k_5]-1)//2
          elif l_2 > k_2 or (k_2 == l_2 and k_5 < l_5):
            ans += A[k_2][k_5]*A[l_2][l_5]          
#print(A)
print(ans)
import sys

# sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))
import sys

# sys.stdin = open('a1.in')


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


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


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    n = read_int()
    a = sorted(read_int_list())
    res = 2 * 10 ** 10
    for i in range(n):
        d = a[i+1] - a[i]
        if res > d:
            res = d
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


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


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    n = read_int()
    a = sorted(read_int_list())
    res = 2 * 10 ** 10
    for i in range(n):
        d = a[i+1] - a[i]
        if res > d:
            res = d
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

# sys.stdin = open('c1.in')


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


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


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    n = read_int()
    a = read_int_list()
    res = 2 * 10 ** 10
    x = 0
    y = sum(a)
    for i in range(n - 1):
        x += a[i]
        y -= a[i]
        d = abs(x-y)
        if res > d:
            res = d
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()
s = input()
ans = 0

def solve(s):
    if all((s[i]==s[i+1] for i in range(len(s)-1))):
        return 0
    for i in range(len(s)-1):
        if s[i:i+2] == '01' or s[i:i+2] == '10':
            return solve(s[:i]+s[i+2:])+2

print(solve(s))

### FIXED CODE ###

s = input()
l0, l1 = 0, 0
for i in s:
    if i == '0':
        l0 += 1
    else:
        l1 += 1
        
print(len(s)-abs(l0-l1))
list = list(int, input().split())

list.sort()

if list[0] == 5 and list[1] == 5 and list[7] == 7:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

# list に入力を格納
list = list(map(int, input().split()))
# 小さい順に並び替え
list.sort()

if list[0] == 5 and list[1] == 5 and list[2] == 7:
    print('YES')
else:
    print('NO')
palindrom = input()
if palindrom != palindrom[::-1]:
  return "No"
n = (len(palindrom)-1)/2
if palindrom[:n] != palindrom[:n:-1]:
  return "No"
n2 = (len(palindrom)+3)/2
if palindrom[:n2] != palindrom[:n2:-1]:
  return "No"
else
	reutn "Yes"

### FIXED CODE ###

s=list(input())
N=len(s)
s2=s[:(N-1)//2]
s3=s[((N+3)-1)//2:N+1]
if s==list(reversed(s)) and s2==list(reversed(s2)) and s3==list(reversed(s3)):
  print("Yes")
else:
  print("No")
import collections
from collections import deque
def tree(s):

    INF=-10**9
    dis = [INF for i in range(n)]
    ans = [INF for i in range(n)]
    dis[s]=0
    def bfs():
        d = deque()
        d.append(s)

        while len(d):
            x = d.popleft()
            cnt=1

            for i in range(len(b[x])):
                y=b[x][i]
                if dis[y] == INF:
                    d.append(y)
                    dis[y]=dis[x]+1
                    if ans[x]!=cnt:
                        ans[y]=cnt
                        cnt+=1
                    else:
                        cnt+=1
                        ans[y]=cnt
                        cnt+=1

        return ans
    return bfs()

n=int(input())
a = [list(map(int, input().split())) for i in range(n-1)]
b = [[] for i in range(n)]

for i in range(n-1):
    b[a[i][0]-1].append(a[i][1]-1)

x=tree(0)
print(max(x))
for i in range(1,n):
    print(x[a[i][1]-1])

### FIXED CODE ###

import collections
from collections import deque
def clear_maze(s):

    INF=-10**9
    ans = [INF for i in range(n)]
    def bfs():
        d = deque()
        d.append(s)

        while len(d):
            v=1
            x = d.popleft()
            for i in range(len(b[x])):
                y=b[x][i]
                if ans[y] == INF:
                    d.append(y)
                    if ans[x]==v:
                        v+=1
                    ans[y]=v
                    v+=1
        return ans
    return bfs()

n=int(input())
a = [list(map(int, input().split())) for i in range(n-1)]
b = [[] for i in range(n)]

for i in range(n-1):
    b[a[i][0]-1].append(a[i][1]-1)


c=clear_maze(0)
print(max(c))
for i in range(n-1):
    print(c[a[i][1]-1])