Harryxun/stf_run huggingface dataset:
n = int(input())
a_L = list(map(int,input().split()))


ans = 0
for i in range(0,len(a_L)-1):
    if a_L[i] > a_L[i+1]:
        ans += abs(a_L[i+1] - a_L[i])
        a_L[i+1] = a_L[i]

if a_L[-1] > a_L[-2]:
    ans += abs(a_L[-1]-a_L[-2])
print(ans)

### FIXED CODE ###

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


if len(a_L) == 1:
    print(0)
    exit()

ans = 0
for i in range(0,len(a_L)-1):
    if a_L[i] > a_L[i+1]:
        ans += abs(a_L[i+1] - a_L[i])
        a_L[i+1] = a_L[i]


if a_L[-2] > a_L[-1]:
    ans += abs(a_L[-1]-a_L[-2])
print(ans)
import  numpy as np
h,w=map(int,input().split())
s = [[0]*(w+2)]
for i in range(h):
    s.append([0]+list(input())+[0])
s.append([0]*(w+2))

t = np.array(s)
c = 0

def sirabe(t,i,j):
    if t[i-1][j] != "#" and t[i][j-1] != "#" and t[i+1][j] != "#" and t[i][j+1] != "#":
        return False
    else:
        return True


for i in range(1,h+1):
    for j in range(1,w+1):
        if sirabe(t,i,j):
            continue
        else:
            c = 1
            break
    if c == 1:
        break

if c == 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

import  numpy as np
h,w=map(int,input().split())
s = [[0]*(w+2)]
for i in range(h):
    s.append([0]+list(input())+[0])
s.append([0]*(w+2))

t = np.array(s)
c = 0
b = 0

def sirabe(t,i,j):
    if t[i-1][j] != "#" and t[i][j-1] != "#" and t[i+1][j] != "#" and t[i][j+1] != "#":
        return False
    else:
        return True


for i in range(1,h+1):
    for j in range(1,w+1):
        if t[i][j] == "#":
            if sirabe(t,i,j):
                continue
            else:
                c = 1
                break
    if c == 1:
        break


if c == 0:
    print("Yes")
else:
    print("No")
a,b,c=map(int,input().split())

if a==b:
  if b==c:
    print("No")
  else:
    printf("Yes")
    
if a!=b:
  if a==c or b==c:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

a,b,c = input().strip().split()

if a==b:
  if b==c:
    print("No")
  else:
    print("Yes")
    
else:
  if a==c or b==c:
    print("Yes")
  else:
    print("No")
from collections import deque

def main()
    n=int(input())
    l=[0]*n
    d={}
    for i in range(n-1):
        a,b,c=map(int,input().split())
        a-=1
        b-=1
        if a in d:
            d[a].add((b,c))
        else:
            d[a]={(b,c)}
        if b in d:
            d[b].add((a,c))
        else:
            d[b]={(a,c)}
    q,k=map(int,input().split())
    k-=1
    p=deque([k])
    while len(p):
        w=p.popleft()
        for i in d[w]:
            if (l[i[0]]==0 and i[0]!=k) or (l[i[0]]!=0 and l[i[0]]>l[w]+i[1]):
                l[i[0]]=l[w]+i[1]
                p.append(i[0])

    for i in range(q):
        x,y=map(int,input().split())
        print(l[x-1]+l[y-1])
if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import deque
n=int(input())
l=[0]*n
d={}
for i in range(n-1):
    a,b,c=map(int,input().split())
    a-=1
    b-=1
    if a in d:
        d[a].add((b,c))
    else:
        d[a]={(b,c)}
    if b in d:
        d[b].add((a,c))
    else:
        d[b]={(a,c)}
q,k=map(int,input().split())
k-=1
p=deque([k])
while len(p):
    w=p.popleft()
    for i in d[w]:
        if (l[i[0]]==0 and i[0]!=k) or (l[i[0]]!=0 and l[i[0]]>l[w]+i[1]):
            l[i[0]]=l[w]+i[1]
            p.append(i[0])

for i in range(q):
    x,y=map(int,input().split())
    print(l[x-1]+l[y-1])
A[:].remove(mx1)

### FIXED CODE ###

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

mx1 = max(A)
A_ = A[:]
A_.remove(mx1)
mx2 = max(A_)
for a in A:
    if a == mx1:
        print(mx2)
    else:
        print(mx1)
N = input()
H = input()
W = input()
print((N - H + 1) * (N - W + 1))

### FIXED CODE ###

N = int(input())
H = int(input())
W = int(input())
print((N - H + 1) * (N - W + 1))
a, b, c = map(str, input().split())
d, e, f = map(str, input().split())
g, h, i = map(str, input().split())
 
print(a+e+i)

### FIXED CODE ###

a = input()
b = input()
c = input()
 
print(a[0]+b[1]+c[2])
n = int(input())
if n % 2 == 1:
    print(0)
else:
    ans = 1
    import math
    for i in range(1, int(math.log(n, 5))):
        ans += n // 2 // (5 ** i)
    print(ans)




### FIXED CODE ###

n = int(input())
if n % 2 == 1:
    print(0)
else:
    ans = 0
    for i in range(1, 26):
        if 5 ** i < n:
            ans += n // 2 // (5 ** i)
    print(ans)
import collections

n = int(input())
v = [int(i) for i in input().split()]

v1 = [v[i] for i in range(0,n,2)]
v2 = [v[i] for i in range(1,n,2)]

count1 = collections.Counter(v1)
count2 = collections.Counter(v2)

if len(count1) == 1 and len(count2) == 1:
    if v1 == v2:
        print(len(v1))
    else:
        print(0)

if v1 == v2:
    res = len(v1) - max(count1.values()) + len(v2) - list(count2.values())[1]
    print(res)

else:
    res = len(v1) - max(count1.values()) + len(v2) - max(count2.values())
    print(res)

### FIXED CODE ###

import collections
 
n = int(input())
v = [int(i) for i in input().split()]
 
v1 = [v[i] for i in range(0,n,2)]
v2 = [v[i] for i in range(1,n,2)]
 
count1 = collections.Counter(v1).most_common(2)
count2 = collections.Counter(v2).most_common(2)

if count1[0][0] != count2[0][0]:
    res = len(v1) - count1[0][1] + len(v2) - count2[0][1]
    print(res)
else:
    if len(count1) == 1:
        print(len(v1))
    else:
        res1 = len(v1) - count1[0][1] + len(v2) - count2[1][1]
        res2 = len(v1) - count1[1][1] + len(v2) - count2[0][1]
        print(min(res1,res2))
X, Y, A, B, C = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a = sorted(a, reverse=True)
b = sorted(b, reverse=True)
c = sorted(c, reverse=True)
#a2 = a[:]
#b2 = b[:]
#c2 = c[:]
sum1 = 0
for i in range(X):
    if a[0] < c[0]:
        sum1 += c.pop(0)
    else:
        sum1 += a.pop(0)
for i in range(Y):
    if b[0] < c[0]:
        sum1 += c.pop(0)
    else:
        sum1 += b.pop(0)
"""
sum2 = 0
for i in range(Y):
    if b2[0] < c2[0]:
        sum2 += c2.pop(0)
    else:
        sum2 += b2.pop(0)
for i in range(X):
    if a2[0] < c2[0]:
        sum2 += c2.pop(0)
    else:
        sum2 += a2.pop(0)
"""
print(sum1)


### FIXED CODE ###

X, Y, A, B, C = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a = sorted(a, reverse=True)[:X]
b = sorted(b, reverse=True)[:Y]
print(sum(sorted(a + b + c, reverse=True)[:X+Y]))
N = int(input())
L = list(map(int, input()))
L.sorted
ans = reduce(lambda x, y: (x + y)/2, L)
print(ans)

### FIXED CODE ###

from functools import reduce
N = int(input())
L = list(map(int, input().split()))
L.sort()
print(reduce(lambda x, y: (x + y)/2, L))
n = int(input())
a = [int(input()) for _ in range(n))]

paper = []
for i in a:
    if i in paper:
        paper.remove(i)
    else:
        paper.append(i)
print(len(paper))

### FIXED CODE ###

from collections import Counter

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

a_c = Counter(a).most_common() 
ans = 0
for i in a_c: 
    if i[1] % 2 == 1:
        ans += 1
print(ans)
n = int(input()

z = 0
for i in range(len(xu)):
    x, y = input().split()
    x = int(x)
    if y == 'JPY':
        z += x
    else:
        z += x*380000
print(z)


### FIXED CODE ###

# ABC119B

n = int(input())

z = 0
for i in range(n):
    x, y = input().split()
    x = float(x)
    if y == 'JPY':
        z += x
    else:
        z += x*380000
print(z)
s = inpu()
if s == 'ARC':
  print('ABC')
else:
  print('ARC')

### FIXED CODE ###

s = input()
if s == 'ARC':
  print('ABC')
else:
  print('ARC')
from sys import stdin
from collections import Counter


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    a_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    count = Counter(a_arr)
    cnt = 0
    keys = sorted(count.keys())
    for key in keys:
        _ = count[key]
        try:
            _ += count[key+1]
        try:
            _ += count[key-1]
        cnt = max(cnt,_)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)

### FIXED CODE ###

from sys import stdin
from collections import Counter


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    a_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    count = Counter(a_arr)
    cnt = 0
    keys = sorted(count.keys())
    for key in keys:
        _ = count[key]
        try:
            _ += count[key+1]
        except:
            pass
        try:
            _ += count[key-1]
        except:
            pass
        cnt = max(cnt,_)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)
import math

a, b, c, d = map(int, input().split())

a_c = (a - 1) // c
a_d = (a - 1) // d
a_cd = (a - 1) // (c * d // math.gcd(c, d))

b_c = b // c
b_d = b // d
b_cd = b // (c * d // math.gcd(c, d))

print((b - b_c - b_d + b_cd) - ((a - 1) - a_c - a_d + a_cd))


### FIXED CODE ###

import fractions

a, b, c, d = map(int, input().split())

a_c = (a - 1) // c
a_d = (a - 1) // d
a_cd = (a - 1) // (c * d // fractions.gcd(c, d))

b_c = b // c
b_d = b // d
b_cd = b // (c * d // fractions.gcd(c, d))

print((b - b_c - b_d + b_cd) - ((a - 1) - a_c - a_d + a_cd))
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def main():
    K = int(input())
    ans = 0
    #全てが同じ数字
    for i in range(1,K+1,1):
        for j in range(1,K+1,1):
            for k in range(1,K+1,1):
                ans += gcd(i,j,k)

    return ans

print(ans)


### FIXED CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def main():
    K = int(input())
    ans = 0
    #全てが同じ数字
    for i in range(1,K+1,1):
        ans += gcd(i,i,i)
    #2つ同じ数字
    tmp = 0
    for i in range(1,K+1,1):
        for j in range(1,K+1,1):
            if j != i:
                tmp += gcd(i,i,j)
    ans += tmp*3
    #3つの異なる数字
    tmp2 = 0
    for i in range(1,K+1,1):
        for j in range(i+1,K+1,1):
            for h in range(j+1,K+1,1):
                tmp2 += gcd(i,j,h)

    ans += tmp2*6

    return ans

print(main())
import math
x1, y1, x2, y2 = map(int, raw_input().split(" "))
print(math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2))

### FIXED CODE ###

import math
x1, y1, x2, y2 = map(float, raw_input().split(" "))
print(math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2))
R = int(input())
G = int(input())

sa = G-B
print(G+sa)


### FIXED CODE ###

R = int(input())
G = int(input())

sa = G-R
print(G+sa)
#! /usr/bin/python
# -*- encoding: utf-8 -*-


if __name__ == '__main__':
    input = list(map(int, input().split()))
    inputA = input[0]
    inputB = input[1]
    
    if inputA < 0:
      sys.stdout.write("IMPOSSIBLE")
        
    elif inputB < 0:
      sys.stdout.write("IMPOSSIBLE")
        
    elif inputA == inputB:
      sys.stdout.write("IMPOSSIBLE")

    elif (inputA + inputB) % 2 == 0:
      sys.stdout.write(int((inputA + inputB) / 2))
      
    elif (inputA + inputB) % 2 != 0:
      sys.stdout.write("IMPOSSIBLE")

    else:
      sys.stdout.write("IMPOSSIBLE")




### FIXED CODE ###

#! /usr/bin/python
# -*- encoding: utf-8 -*-

import sys

if __name__ == '__main__':
    input = list(map(int, input().split()))
    inputA = input[0]
    inputB = input[1]
    
    if inputA < 0:
        sys.stdout.write("IMPOSSIBLE")
        sys.exit()
    
    if inputB < 0:
        sys.stdout.write("IMPOSSIBLE")
        sys.exit()

    if inputA == inputB:
        sys.stdout.write("IMPOSSIBLE")
        sys.exit()

    if (inputA + inputB) % 2 == 0:
        sys.stdout.write(str(int((inputA + inputB) / 2)))
        sys.exit()
      
    sys.stdout.write("IMPOSSIBLE")
    sys.exit()
n=input()
if n%2!=0:
  print("No")
else:
  if n[:n//2]==n[n//2:]:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

a=int(input())
b=input()
if a%2 == 0:
  if b[:a//2]==b[a//2:]:
    print("Yes")
  else:
    print("No")
else:
  print("No")
H,W = list(map(int,input().split()))

A = [list(str(input())) for i in range(H)]

white = []
black = []

length = sum([a.count(".") for a in A])
cnt = 0

while (length > 0):
    gray = []
    for i in range(W):
        for j in range(H):
            if A[i][j] == "#":
                black.append([i,j])
            else:
                white.append([i,j])
       
    for l in white:
        if [l[0],l[1]-1] in black or [l[0],l[1]+1] in black or [l[0]-1,l[1]] in black or [l[0]+1,l[1]] in black:
            gray.append(l)

    for l in gray:
        black.append(l)
        white.remove(l)
        
    cnt += 1
    length = len(white)
    
print(cnt)

### FIXED CODE ###

H,W = list(map(int,input().split()))
A = [list(str(input())) for i in range(H)]
 
black = []
 
cnt = 0
 
for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            black.append([i,j])
 
length = len(black)
            
while (length < H*W):
    gray = []
    for l in black:
        if l[1] != 0:
            c1 = (l[0],l[1]-1)
            if A[c1[0]][c1[1]] == ".":
                gray.append(c1)
                A[c1[0]][c1[1]] = "#"
        if l[1] != W-1:
            c2 = (l[0],l[1]+1)
            if  A[c2[0]][c2[1]] == ".":
                gray.append(c2)
                A[c2[0]][c2[1]] = "#"
        if l[0] != 0:
            c3 = (l[0]-1,l[1])
            if  A[c3[0]][c3[1]] == ".":
                gray.append(c3)
                A[c3[0]][c3[1]] = "#"
        if l[0] != H-1:
            c4 = (l[0]+1,l[1])
            if  A[c4[0]][c4[1]] == ".":
                gray.append(c4)
                A[c4[0]][c4[1]] = "#"
    
    gray = list(set(gray))
    black = [l for l in gray]
    
    cnt += 1
    length += len(black)
    
print(cnt)
a,b,c = map(int, input().split())

if a**2 + 2*math.sqrt(a*b)+b**2 < c**2:
  print('yes')
else:
  print('no')

### FIXED CODE ###

a,b,c = map(int,input().split())

if (c-a-b)>0 and 4*a*b<(c-a-b)**2:
  print('Yes')
else:
  print('No')
a,p=map(int,input().split())
print((3a+p)//2)

### FIXED CODE ###

a,p=map(int, input().split())
print((3*a+p)//2)
import math
x1, y1, x2, y2 = map(int, input().split())
print(math.sqrt((y2-y1)**2 + (x2-x1)**2))



### FIXED CODE ###

x1, y1, x2, y2 = map(float, input().split())
print(((y2-y1)**2 + (x2-x1)**2)**(1/2))
N,M=map(int,input().split())
keep=[]
lis=[]
ac=[0]*N
wa=[0]*N
WA=0
for i in range(M):
    ps=input().split()
    keep.append(ps)
    
for j in range(M):
    if keep[j][1]=="AC":
        print(int(keep[j][0]))
        ac[int(keep[j][0])]=1
    elif ac[int(keep[j][0])]==0:
        wa[int(keep[j][0])]+=1
AC=sum(ac)
for j in range(M):
    WA+=ac[j]*wa[j]
    
print(AC,WA)

### FIXED CODE ###

N,M=map(int,input().split())
keep=[]
lis=[]
ac=[0]*N
wa=[0]*N
WA=0
for i in range(M):
    ps=input().split()
    keep.append(ps)
    
for j in range(M):
    if keep[j][1]=="AC":
        ac[int(keep[j][0])-1]=1
    elif ac[int(keep[j][0])-1]==0:
        wa[int(keep[j][0])-1]+=1
AC=sum(ac)
for k in range(N):
    WA+=ac[k]*wa[k]
    
print(AC,WA)
a=input()
list_1=list(a)
length=len(list_1)
count=0
for k in range(0,length,2):
  if list_1[k]=='h' and list_1[k+1]=='i':
    count+=2
    if count==length:
      print("Yes")
      break
    else:
      continue
  else:
    print("No")
    

### FIXED CODE ###

a=input()
list_1=list(a)
length=len(list_1)
count=0
if length%2==1:
  print("No")
else:
  for k in range(0,length,2):
    if list_1[k]=='h' and list_1[k+1]=='i':
      count+=2
      if count==length:
        print("Yes")
        break
    else:
      continue
  else:
    print("No")
a,b,c=input().split(".")
print(a,b,c)

### FIXED CODE ###

a,b,c=input().split(",")
print(a,b,c)
nlist = [int(input()) for i in range(5)]
#print(nlist)
total_time=0
tail=[]
for number in nlist:
    if number % 10 == 0:
        total_time += number
    else:
        total_time += (number+10-(number%10))
        tail.append(number%10)

total_time -= (10-min(tail))
print(total_time)


### FIXED CODE ###

nlist = [int(input()) for i in range(5)]
#print(nlist)
total_time=0
tail=[]
for number in nlist:
    if number % 10 == 0:
        total_time += number
    else:
        total_time += (number+10-(number%10))
        tail.append(number%10)
if tail:
    total_time -= (10-min(tail))
print(total_time)
N = input()
ans = int((N+1) / 2)
print(ans)

### FIXED CODE ###

N = int(input())
ans = int((N+1) / 2)
print(ans)
n = int(input())
p = list(map(int, input().split()))

cnt = 0
for i in range(1, n):
    if (p[i] - p[i - 1] > 0 and p[i + 1] - p[i] >= 0) or (p[i] - p[i - 1] <= 0 and p[i + 1] - p[i] < 0):
        cnt += 1
print(cnt)

### FIXED CODE ###

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

cnt = 0
for i in range(1, n - 1):
    if (p[i] - p[i - 1] > 0 and p[i + 1] - p[i] >= 0) or (p[i] - p[i - 1] <= 0 and p[i + 1] - p[i] < 0):
        cnt += 1
print(cnt)
S = list(input())
n = (len(S)-1)//2
for i in range(n):
  if S[i] == S[-(i+1)] and S[i] == S[i+n+1]:
    continue
  else:
    print('No')
for i in 
print('Yes')

### FIXED CODE ###

S = list(input())
n = (len(S)-1)//2
m = 0
for i in range(n):
  if S[i] == S[-(i+1)] and S[i] == S[i+n+1]:
    continue
  else:
    print('No')
    m = 1
    break
if m < 1:
  print('Yes')
from math import gcd

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

res = 1L
for t in T:
  res = long(res * t /(gcd(res, t)))
print(res)

### FIXED CODE ###

from fractions import gcd

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

res = 1
for t in T:
  res = res // gcd(res, t) * t
print(res)
import math
r = input()
print(2 * math.pi * r)

### FIXED CODE ###

import math

r = int(input())
print(2 * math.pi * r)
import math;r=int(input());print(math.pi*(r**2),2*math.pi*r)

### FIXED CODE ###

import math;r=float(input());print(math.pi*(r**2),2*math.pi*r)
S = input()

AGCT = {"A", "G", "C", "T"}

j = 0
l = 0
l_log = []

while j < len(S):
    if S[j] in AGCT:
        j += 1
        l += 1
    else:
        l_log.append(l)
        l = 0
        j += 1

print(max(l_log))


### FIXED CODE ###

S = input()

AGCT = {"A", "G", "C", "T"}

j = 0
l = 0
l_log = []

while j < len(S):
    if S[j] in AGCT:
        l += 1
        if j == len(S) - 1:
            l_log.append(l)
    else:
        l_log.append(l)
        l = 0
    j += 1

print(max(l_log))
a=int(input())
b=list(input())
c=0
for i in range(a):
  if b[i]=="A":
    if b[i+1]=="B":
    
      if b[i+2]=="C":
        c+=1
      
print(c)


### FIXED CODE ###

n=int(input())
s=list(input())
d=0
for i in range(n):
  if n-(i+1)>=2:
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
      d+=1
  else:
    pass
print(d)
a, b, c, d, e, k = map(int, input().split())
if e-a <= k:
    print('Yay!')
else:
    print(':(')


### FIXED CODE ###

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

if val[4]-val[0] <= val[5]:
    print('Yay!')
else:
    print(':(')
def insertionSort(A,g):
    global cnt
    
    for i in range(g,len(A)):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
            A[j+g] = v
            
def shellSort(A):
    global cnt
    cnt = 0
    h = 1
    g = []
    while h <= len(A):
        g.append(h)
        h = 3*h+1
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str,g)))
    for i in range(m):
        insertionSort(A,g[i])

    

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


shellSort(A)
print(cnt)
for i in A:
    print(i)


### FIXED CODE ###

def insertionSort(A,g):
    global cnt
    
    for i in range(g,len(A)):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
            
def shellSort(A):
    global cnt
    cnt = 0
    h = 1
    g = []
    while h <= len(A):
        g.append(h)
        h = 3*h+1
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str,g)))
    for i in range(m):
        insertionSort(A,g[i])

    

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


shellSort(A)
print(cnt)
for i in A:
    print(i)
mtlist=[]

while True:
    mtlist.append(input())
    mt
print(list.sort())

### FIXED CODE ###

import sys
heights = sorted([ int(h) for h in sys.stdin ], reverse=True)
print( heights[0] )
print( heights[1] )
print( heights[2] )
while True:
    m, n = map(int, input().split())
    if m == 0:
        break
    player = list(range(1, m+1))
    idx = 0
    for i in range(1, n+1):
        ans = "Fizz"*(i%3==0) + "Buzz"*(i%5==0) or str(i)
        if ans == input():
            idx += 1
        else:
            player.pop(idx)
            if len(player) == 1:
                break
        idx %= len(player)
    print(*player)

### FIXED CODE ###

hoge = ["FizzBuzz" if i % 15 == 0 else("Fizz" if i % 3 == 0 else("Buzz" if i % 5 == 0 else str(i))) for i in range(10001)]

while True:
    m, n = map(int, input().split())
    if m == 0:
        break
    man = list(range(1, m+1))
    game = [input() for _ in range(n)]
    idx = 0
    for i in range(n):
        if game[i] != hoge[i+1]:
            del man[idx]
            if len(man) == 1:
                break
        else:
            idx += 1
        idx %= len(man)
    print(*man)
sys.setrecursionlimit(100000)
    N = int(input())
    path = [[] for _ in range(N + 1)]
    for _ in range(N - 1):
        u, v, w = map(int, input().split())
        # 無向グラフ
        path[u].append((v, w))
        path[v].append((u, w))
    # d[0]は使わない
    d = [-1] * (N + 1)

    def walk(i, c):
        if d[i] == -1:
            d[i] = c
            for x, w in path[i]:
                walk(x, c + w)

    walk(1, 0)
    for c in d[1:]:
        print(c)

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

def tree_path():
    # 辺と長さが与えられる
    # 頂点1からの各点の距離を計算する
    # 距離が偶数か奇数かで色分け
    sys.setrecursionlimit(100000)
    n = int(input())
    path = [[] for _ in range(n + 1)]
    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        # 無向グラフ
        path[u].append((v, w))
        path[v].append((u, w))
    # d[0]は使わない
    d = [-1] * (n + 1)

    def walk(i, c):
        if d[i] == -1:
            d[i] = c
            for x, w in path[i]:
                walk(x, c + w)

    walk(1, 0)
    for i in d[1:]:
        print(i % 2)

        
tree_path()
def main():
    n = int(input())
    A = list(map(int, input().split()))

    A_sorted = sorted(A, reverse=True)
    flag = True
    res = 0

    for i in range(n-1):
        flag = True
        for j in range(i+1,n):
            if (A_sorted[i] % A_sorted[j] == 0):
                flag = False
                break
        
        if flag:
            res += 1
    
    if A_sorted[-2] == A_sorted[-1]:
        print(res)
    else:
        print(res+1)


if __name__ == '__main__':
    main()

### FIXED CODE ###

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    n = int(input())
    A = sorted(list(map(int, input().split())))

    multiples = [1] * (10 ** 6 + 1)

    bucket = Counter(A)
    res = 0

    for num in A:
        if bucket[num] == 1 and multiples[num] == 1:
            res += 1
        if multiples[num] == 1:
            for i in range(num, 10**6+1, num):
                multiples[i] = 0
    
    print(res)

if __name__ == '__main__':
    main()
S = input()
List = ["Sunny", "Cloudy", "Rainy"]
res = 0
for i in range(3):
  if S == List[i]:
    res = i+1
if res == 2:
  res = 0
print(List[res])

### FIXED CODE ###

S = input()
List = ["Sunny", "Cloudy", "Rainy"]
res = 0
for i in range(3):
  if S == List[i]:
    res = i+1
if res == 3:
  res = 0
print(List[res])