Harryxun/stf_run huggingface dataset:
data = [
        [
            [
                0 for r in range(10)
            ] for f in range(3)
        ] for b in range(4)
]

n = int(input())

for _ in range(n):
    (b, f, r, v) = [int(i) for i in input().split()]
    data[b - 1][f - 1][r - 1] += v


for b in range(4):
    for f in range(3):
        for r in range(10):
            print('', data[b][f][r], end='')
        print()
    if b < 3:
        print('#' * 20)
    else:
        print()

### FIXED CODE ###

cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
        }
  
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    r = int(r)
    cards[s][r - 1] = r
  
for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print( '{0:s} {1:d}'.format(s, r+1))
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
N = int(input())
a = list(map(int,input().split()))
if N==2:
    print(max(a))
else:
    gcd1 = gcd(a[0],a[1])
    gcd2 = gcd(a[0],a[2])
    gcd3 = gcd(a[1],a[2])
    flag1 = flag2 = flag3 = 0
    for i in range(N):
        if a[i]%gcd1 == 0:
            flag1 += 1
        if a[i]%gcd2 == 0:
            flag2 += 1
        if a[i]%gcd3 == 0:
            flag3 += 1
    ans = []
    if flag1 == N-1:
        ans.append(gcd1)
    if flag2 == N-1:
        ans.append(gcd2)
    if flag3 == N-1:
        ans.append(gcd3)
    print(max(ans))

### FIXED CODE ###

def gcd(a,b):
    if a < b:
        a,b = b,a
    if b == 0:
        return a
    return gcd(b,a%b)

n = int(input())
a = list(map(int, input().split()))
rs, ls = [0], [0]
for i in range(n-1):
    rs.append(gcd(rs[i], a[i]))
    ls.append(gcd(ls[i], a[-i-1]))
gcd_list = [gcd(r,l) for r, l in zip(rs, ls[::-1])]
print(max(gcd_list))
from bisect import bisect_left

n, k = map(int, input().split())
x = list(map(int, input().split()))
if 0 in x:
    x.remove(0)
    k -= 1
    n -= 1

if n == 0:
    print(0)
else:
    si = bisect_left(x, 0)

    ans = x[-1] - x[0]
    if si + k - 1 < len(x):
        ans = min(ans, x[si + k - 1])
    if si - k >= 0:
        ans = min(ans, abs(x[si - k]))

    for i in range(n):
        tmp_ans = 0
        if i < si and i + k -1 < len(x):
            tmp_ans = abs(x[i]) * 2 + x[i + k - 1]
            ans = min(ans, tmp_ans)
        elif i - k + 1 >= 0:
            tmp_ans = x[i] * 2 + abs(x[i - k + 1])
            ans = min(ans, tmp_ans)

    print(ans)


### FIXED CODE ###

n, i = map(int, input().split())

print(n-i+1)
import math
X=int(input())

for i in range(X+1):
  #print(pow(X-pow(i,5),1/5),i)
  if pow(X-pow(i,5),1/5)%1==0:
    break
print(int(pow(X-pow(i,5),1/5)),-i)

### FIXED CODE ###

import math
X=int(input())
c=0
for i in range(200):   
  for j in range(-200,200):
    if i**5-j**5==X:
      c=1
      break
      
  if c==1:
    break
      
print(i,j)
n,k=int(input()).split()
a=list(input().split())
for i in range(k):
  a.remove(max(a))
print(sum(a))

### FIXED CODE ###

n,k=list(map(int,input().strip().split(' ')))
h=list(map(int,input().strip().split(' ')))
h.sort()
if(k!=0): print(sum(h[:-k]))
else: print(sum(h))
import numpy as np

i=[int(input()) for i in range(3)]
print(i)
if i[0]==i[1]&i[1]!=i[2]:
  print('Yes')
elif i[0]==i[2]&i[1]!=i[2]:
  print('Yes')
elif i[1]==i[2]&i[0]!=i[1]:
  print('Yes')
else:
  print('no')


### FIXED CODE ###

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

if  A==B==C:
    print('No')
elif A!=B and A!=C and B!=C:
    print('No')
else:
    print('Yes')
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m = LI()
    e = collections.defaultdict(list)
    for _ in range(m):
        l,r,d = LI()
        e[l-1].append((r-1,d))
        e[r-1].append((l-1,-d))

    b = [False] * n
    def g(i,c):
        if b[i] != False:
            if c == False:
                return True
            return b[i] == c
        if c == False:
            c = 0
        b[i] = c
        for r,d in e[i]:
            if not g(r,c+d):
                return False
        return True

    for i in range(n):
        if not g(i,False):
            return 'No'
    return 'Yes'


print(main())




### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m = LI()
    e = [[] for _ in range(n)]
    if m > 0:
        for _ in range(m):
            l,r,d = LI()
            e[l-1].append((r-1,d))
            e[r-1].append((l-1,-d))

    b = [None] * n

    for i in range(n):
        if not b[i] is None:
            continue
        b[i] = 0
        q = [i]
        qi = 0
        nq = []
        while True:
            if len(q) == qi:
                if not nq:
                    break
                q = nq
                qi = 0
                nq = []
            j = q[qi]
            qi += 1
            c = b[j]
            for r,d in e[j]:
                if b[r] is None:
                    b[r] = c+d
                    nq.append(r)
                else:
                    if b[r] != c+d:
                        return 'No'

    return 'Yes'


print(main())
A, B = map(int, input())

for p in range(13, A):
	if int(p * 0.08) == A and int(p * 0.1) == B:
		print(p)
		exit()

print(-1)


### FIXED CODE ###

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

for p in range(13, 1250):
	if int(p * 0.08) == A and int(p * 0.1) == B:
		print(p)
		exit()

print(-1)
S = input()

answer = "Good"
prev_s = s[0]
for s in S[1:]:
  if prev_s == s:
    answer = "Bad"
    break
  prev_s = s

print(answer)

### FIXED CODE ###

S = input()
 
answer = "Good"
prev_s = S[0]
for s in S[1:]:
  if prev_s == s:
    answer = "Bad"
    break
  prev_s = s
 
print(answer)
O = input()
E = input()
X = ""

for i in range(len(E)):
    X += (O[i] + E[i])

if len(O) != len(E):
    X += O[-1]
    
print(X)
    

### FIXED CODE ###

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

if b - a == c - b:
    print("YES")
else:
    print("NO")
from math import factorial
N, a, b = map(int, input().split())
m=0
for i in range(N):
    if not i== a-1 or i==b-1:
        k=factorial(N) // (factorial(N - (i+1)) * factorial(i+1))
        m=m+k
    print(m)


### FIXED CODE ###

N,R=map(int, input().split()) 
if N>=10:
    print(R)
if 0<=N<10:
    print(R+100*(10-N))
n = int(input())
test_list = [[[int(i) for i in input().split()] for j in range(int(input()))] for k in range(n)]
    
man_list = [[int(j) for j in bin(i)[2:].zfill(n)] for i in range(2**n)]
    
ans = 0
bad = 0
    
for man in man_list:
    for j in range(n):
        if man[j] == 1:
            for k in test_list[j]:
            x = k[0] - 1
            y = k[1]
            if man[x] != y:
                bad = 1
                break
        if bad == 1:
            bad = 0
            break
        else:
            ans = max(ans, sum(man))
    
print(ans)

### FIXED CODE ###

n = int(input())

times = n
table = []
for _ in range(times):
    a = int(input())
    temp = []
    for _ in range(a):
        x , y = map(int,input().split())
        temp.append([x-1,y])
    table.append(temp)  


def check(i,n):
    flg = True
    for j in range(n):
        if i>>j & 1:
            for x,y in table[j]:
                if (i>>x)&1 != y:
                    flg = False
                    return flg
    return flg
ans = 0
for i in range(2**n):
    if check(i,n):
        ans = max(bin(i).count("1"),ans)

print(ans)
import numpy as np

N, K = map(int, input().split())
A = np.array([0] + list(map(int, input().split())))

B = (np.add.accumulate(A) - np.arange(N+1)) % K

count = [0] * K
ans = 0

for j in range(N+1):
    if j - K >= 0:
        count[B[j-K]] -= 1
    ans += count[B[j]]
    count[B[j]] += 1

print(ans)


### FIXED CODE ###

import numpy as np
from collections import defaultdict

N, K = map(int, input().split())
A = np.array([0] + list(map(int, input().split())))

B = (np.add.accumulate(A) - np.arange(N+1)) % K

counter = defaultdict(int)
ans = 0

for j in range(N+1):
    if j - K >= 0:
        counter[B[j-K]] -= 1
    ans += counter[B[j]]
    counter[B[j]] += 1

print(ans)
a,b = map(int, input().strip().split(' '))
print(a*b if 1 <= a <= 9 and <= b <= 9 else -1)


### FIXED CODE ###

a,b = map(int, input().strip().split(' '))
print(a*b if 1 <= a <= 9 and 1 <= b <= 9 else -1)
s = raw_input()
print(s.count("+")-s.count("-"))


### FIXED CODE ###

print(4-input().count("-")*2)
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a,b,c=mi()
l=[0]*a
for i in range(c):
  j=ii()
  l[i-1]+=1
for k in l:
  if b+k-c>0:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a,b,c=mi()
l=[0]*a
for i in range(c):
  j=ii()
  l[j-1]+=1
for k in l:
  if b+k-c>0:
    print("Yes")
  else:
    print("No")
k = int(input())
a, b = map(int, input().split())

flag = False
for i in range(a, b+1):
	if i % k == 0:
    	flag = True

print("OK") if flag else print("NG")

### FIXED CODE ###

k = int(input())
a, b = map(int, input().split())
 
flag = False
for i in range(a, b+1):
    if i % k == 0:
        flag = True
 
print("OK") if flag else print("NG")
n = int(input())
s = str(input())
count = 0
for i in range(n):
    if s[i] == 'a' or s[i] == 'A':
        if i + 1 <= n:
            if s[i + 1] == 'b' or s[i + 1] == 'B':
                if i + 2 <= n:
                    if s[i + 2] == 'c' or s[i + 2] ==  'C':
                        count += 1
print(count)

### FIXED CODE ###

n = int(input())
s = str(input())
count = 0
for i in range(n):
    if s[i] == 'a' or s[i] == 'A':
        if i + 1 < n:
            if s[i + 1] == 'b' or s[i + 1] == 'B':
                if i + 2 < n:
                    if s[i + 2] == 'c' or s[i + 2] ==  'C':
                        count += 1
print(count)
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)

ans1, ans2 = 0,0

maxA = max(A)
B = [1]
t = 1
while t < maxA:
    t *= 2
    B.append(t)

d = dict()
for i in range(N):
    if A[i] in B:
        ans1 += 1
        M -= 1
    else:
        if A[i] in d:
            d[A[i]] += 1
        else:
            d[A[i]] = 1

for i in range(N):
    if A[i] not in B:
        t = 2**len(bin(A[i])[2::]) - A[i]
        if t in d:
            if d[t] > 0:
                ans2 += 1
                d[t] -= 1
                d[A[i]] -= 1

print(ans1+ans2)

### FIXED CODE ###

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

ans1, ans2 = 0,0

maxA = max(A)
B = [1]
t = 1
while t < maxA:
    t *= 2
    B.append(t)

d = dict()
for i in range(N):
    if A[i] in d:
        d[A[i]] += 1
    else:
         d[A[i]] = 1

for i in range(N):
    t = 2**len(bin(A[i])[2::]) - A[i]
    if t in d:
        if t != A[i]:
            if d[t]>0 and d[A[i]]>0:
                ans2 += 1
                d[t] -= 1
                d[A[i]] -= 1
        else:
            if d[t] > 1:
                ans2 += 1
                d[t] -= 2


print(ans1+ans2)
#C
N=int(input())
alp=list(a)
Name=[]
for i in reversed(range(11)):
    if N/(26**i) >=1:
        alp_index=N//(26**i)-1 if N//(26**(i-1))!=26 else 25
        Name.append(alp[alp_index])
    N=N%(26**i)
print(''.join(Name))

### FIXED CODE ###

#A
x = input()
if x.isupper() ==True:
    print('A')
else:
    print('a')
s=[int(i) for i in input()]
s.reverse()

a=0
l=[0 for i in range(2019)]
l[0]=1
for i in range(len(s)):
  a+=s[i]*(10**i)
  a%=2019
  l[b]+=1

answer=0
for i in range(2019):
  answer+=l[i]*(l[i]-1)//2
  
print(answer)

### FIXED CODE ###

s=[int(i) for i in input()]
s.reverse()

a=0
l=[0 for i in range(2019)]
l[0]=1
b=0.1
for i in range(len(s)):
  b=int(b*10)
  b%=2019
  a+=s[i]*b
  a%=2019
  l[a]+=1

answer=0
for i in range(2019):
  answer+=l[i]*(l[i]-1)//2
  
print(answer)
import numpy as np
n,k=map(int,input().split())
s=list(input())
s[k]=s[k].lower()
for i in range(len(s)):
  print(s[i],end="")
#print()

### FIXED CODE ###

n,k=map(int,input().split())
s=list(input())
s[k-1]=s[k-1].lower()
s="".join(s)
print(s)
import sys
input = sys.stdin.readline

def main():
    s = input()[:-1]
    q = int(input())
    tmp = [input().split() for _ in range(q)]

    for i in range(len(tmp)):
        if len(tmp[i]) == 1:
            s = s[::-1]
        else:
            if int(tmp[i][1]) == 1:
                s = tmp[i][2] + s
            else:
                s = tmp[i][2] + c
                
    print(s)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
from collections import deque

def main():
    input = sys.stdin.readline

    s = input()[:-1]
    q = int(input())
    tmp = [input().split() for _ in range(q)]

    flag = 0
    ans = deque([s])
    for t in tmp:
        if len(t) == 1:
            flag = ~flag 
        else:
            f = int(t[1])
            c = t[2]
            if (f == 1 and flag == 0) or (f ==2 and flag == -1):
                ans.appendleft(c)
            else:
                ans.append(c)
    if flag == 0:
        print(''.join(ans))
    else:
        print(''.join(ans)[::-1])

if __name__ == '__main__':
    main()
N, K = map(int, input().split())
al = list(map(int, input().split()))

route = [1]
for i in range(N):
    next_town = al[route[i] - 1]
    if route.count(next_town) ==1 :
        loop_start = route.index(next_town)
        loop_end = len(route)
        loop_length = loop_end - loop_start
        if K >= loop_end:
            amari = (K - loop_start) % loop_length
            ans = route[loop_start + amari]
            # print(route)
            print(ans)
            exit()
    else:
        route.append(next_town)

ans = route[-1]
print(ans)


### FIXED CODE ###

from collections import defaultdict


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


N, K = inpl()
aa = inpl()

s = 1

route = [s]
ed = set([s])

for i in range(1, K + 1):
    s = aa[s - 1]
    if s in ed:
        Li = route.index(s)
        Ri = len(route)
        idx = Li + (K - Li) % (Ri - Li)
        print(route[idx])
        break
    else:
        route.append(s)
        ed.add(s)
        continue
else:
    print(s)
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    print(int(n / 2 * (n - 1)))

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return str(sys.stdin.readline())

def main():
    s = S()
    t = S()
    ans = 0
    for i in range(3):
        if s[i] == t[i]:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()
def chmin(a, b):
    if a > b:
        return b
    else:
        return a
import numpy as np  
n,k = map(int,input().split())
h = np.array([int(i) for i in input().split()],dtype = np.int32)
# dpの最小値を変更する関数

# 無限大の値
f_inf = 10 ** 9 
# DP テーブルを初期化　(最小化問題なので INF に初期化)
dp = np.array([f_inf] * (10**5+10), dtype =np.int32)
# 初期条件
dp[0] = 0
# 足場 i-1 から足場 i へ移動する。コストは|h[i]−h[i-1]|
# 足場 i-2 から足場 i へと移動する コストは |h[i]−h[i-2]|
for i in range(1, n):
    for j in range(1,k+1):
        if i-j < 0 :
            continue
        else:
            dp[i] = chmin(dp[i], dp[i - j] + abs(h[i] - h[i-j]))
print(dp[n-1])

### FIXED CODE ###

import sys
input = sys.stdin.readline
def chmin(a, b):
    if a > b:
        return b
    else:
        return a
  
n,k = map(int,input().split())
h = [int(i) for i in input().split()]
# dpの最小値を変更する関数

# 無限大の値
f_inf = 10 ** 9 
# DP テーブルを初期化　(最小化問題なので INF に初期化)
dp = [f_inf] * (10**5+10)
# 初期条件
dp[0] = 0
# 足場 i-1 から足場 i へ移動する。コストは|h[i]−h[i-1]|
# 足場 i-2 から足場 i へと移動する コストは |h[i]−h[i-2]|
for i in range(1, n):
    for j in range(1,k+1):
        if i-j < 0 :
            continue
        else:
            dp[i] = chmin(dp[i], dp[i - j] + abs(h[i] - h[i-j]))
print(dp[n-1])
import bisect

n = int(input())
count = 0
a = [[0 for i in range(n)] for i in range(3)]

for i in range(3):
    a[i] = [int(x) for x in input().split()]
    a[i].sort()

# Binary Search
for i in a[1]:
    index0_left = bisect.bisect_left(a[0], i)
    while i == a[0][index0_left-1]:
        if index0_left == 0:
            break
        index0_left -= 1

    index2_right = bisect.bisect_right(a[2], i)
    while a[2][index2_right+1] == i:
        if index2_right > n:
            break
        index2_right += 1

    if ( i > a[0][index0_left-1] and a[2][index2_right+1] > i):
        count += (index0_left)*( n - index2_right)



### FIXED CODE ###

import bisect

n = int(input())
count = 0
a = [[0 for i in range(n)] for i in range(3)]

for i in range(3):
    a[i] = [int(x) for x in input().split()]
    a[i].sort()

# Binary Search
for i in a[1]:
    index0_left = bisect.bisect_left(a[0], i)

    index2_right = bisect.bisect_right(a[2], i)

    count += (index0_left -1 + 1)*(n - index2_right)

print(count)
a, b, c = map(int, input())

print(a * b / 2)


### FIXED CODE ###

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

print(int(a * b / 2))
# 迷路読み込み
h,w = map(int, input().split())
maze=[list(input()) for i in range(h)]

import collections
from collections import deque

INF = -10 ** 9
distance = [[INF for i in range(w)] for j in range(h)]
d = deque()
def bfs():
    cnt=0
    while len(d):
        x, y = d.pop()
        for i in range(0, 4):
            nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]

            if (0 <= nx <=w-1 and 0 <= ny<=h-1 and distance[nx][ny] == INF):
                d.appendleft((nx, ny))
                distance[nx][ny] = distance[x][y] + 1
                if cnt<distance[nx][ny]:
                    cnt=distance[nx][ny]

    return cnt


for i in range(h):
    for j in range(w):
        if maze[i][j]=='#':
            d.append((i,j))
            distance[i][j]=0
print(bfs())

### FIXED CODE ###

from collections import deque
 
h, w = map(int, input().split())
s = [input() for i in range(h)]
 
d = [[h+w for j in range(w)] for i in range(h)]
que = deque()
 
#黒だったらスタートキューに入れる
for i in range(h):
  for j in range(w):
    if s[i][j]=='#':
        que.append((i, j))
        d[i][j] = 0
 
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
 
 
while que:
    p = que.popleft()
    # 黒にする4方向をループ
    for i in range(4):
        nx = p[1] + dx[i]
        ny = p[0] + dy[i]
 
        if (0<=nx<w) and (0<=ny<h) and (d[ny][nx]==h+w):
            que.append((ny, nx))
            d[ny][nx] = d[p[0]][p[1]] + 1
 
res = max(map(max, d))
print(res)
n = int(input())

ls = list(map(int, input().split()))
 
count = 0

for i in range(n-2):
    if a[i-1] < a[i] and a[i+1] > a[i]:
        count+=1
    else:
        if a[i-1] > a[i] and a[i+1] < a[i]:
            count += 1

print count

### FIXED CODE ###

n = int(input())

ls = list(map(int, input().split()))
 
count = 0

for i in range(1,n-1):
    if ls[i-1] < ls[i] and ls[i+1] > ls[i]:
        count+=1
    elif ls[i-1] > ls[i] and ls[i+1] < ls[i]:
            count += 1

print(str(count))
n=int(input())
l=list(map(int,input().split()))
l.sort()
sum=1#個数
if l[0]==l[1]:
  sum=0
for j in range(1,n):
  i=1
  for m in range(0,j):
    if l[j]%l[m]==0:
      i=0
      break
  sum+=i
    
print(sum)

### FIXED CODE ###

l=list(map(int,input().split()))
for i in range(5):
  if l[i]==0:
    print(i+1)
    break
import math

n=int(input())

res=1
for _ in range(n):
    x=int(input())
    res=res//math.gcd(res,x)*x
print(res)


### FIXED CODE ###

#from math import gcd
from fractions import gcd

n=int(input())

res=1
for _ in range(n):
    x=int(input())
    res=res//gcd(res,x)*x
print(res)
a=input()
print(a*a)

### FIXED CODE ###

a=int(input())

print(a*a)
import re

n = int(input())
v = sorted(list(map(int, input().split())))

ans = (v[0]+v[1])/2

if n == 2:
    ans = ans

elif n > 2 and n % 2 == 0:
    for i in range(n/2):
        ans = (ans + v[i+2])/2

else:
    for i in range(n-2):
        ans = (ans + v[i+2])/2

if re.search('.0', str(ans)):
    ans = str(ans).replace('.0', '')
    print(ans)

else:
    print(ans)

### FIXED CODE ###

n = int(input())
v = sorted(list(map(int, input().split())))

ans =v[0]

for i in range(n-1):
        ans = (ans + v[i+1])/2
print(ans)
# -*- coding: utf-8 -*-
import sys

def main():
	N = int(input())
	
	btnList = []
	for _ in range(N):
		tmp = int(input())
		btnList.append(tmp)
	
	tugi = btnList[0]
	lists = [0]
	while True:
		lists.append(tugi-1)
		tugi = btnList[tugi-1]
		print(lists)
		if tugi-1 == 1:
			print(len(lists))
			sys.exit()
		if (tugi-1) in lists:
			print(-1)
			sys.exit()
	
if __name__ == "__main__":
	main()
	

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys

def main():
	N = int(input())
	ai = [int(input()) for i in range(N)]
	
	now = 1
	count = 0
	for i in range(N):
		count = count + 1
		now = ai[now-1]
		if now == 2:
			print(count)
			exit()
	print(-1)
	
if __name__ == "__main__":
	main()