Harryxun/stf_run huggingface dataset:
n = int(input())
d = list(map(int,input().split()))
if d[0] != 0:
    print(0)
else:
    ans = 1
    most_far = max(d)
    for i in range(most_far-1):
        ans *= d.count(most_far - (i+1))**d.count(most_far-i)
print(ans)

    
    

### FIXED CODE ###

from collections import Counter
mod = 998244353
n = int(input())
d = list(map(int,input().split()))
if d[0] != 0:
    print(0)
    exit()

C = Counter(d)
C = dict(sorted(C.items()))

memo1 = C[1]
memo2 = 1
ans = 1

for i in range(1,n):
    if d[i] == 0:
        print(0)
        exit()

for key in C:
    if key >= 2:
        if memo2 + 1 != key: #道が途切れている場合はダメ
            print(0)
            exit()
        ans = (ans * memo1 ** C[key]) % mod #modは和について閉じているため先にわる
        memo1 = C[key]
        memo2 = key
print(ans)
a,b,c=map(int,input().split())
ans=[]
ans.append(a)
ans.append(b)
ans.append(c)
ans.sort(reverse=True)
temp=""
temp+=ans[0]
temp+=ans[1]
print(int(temp)+ans[2])


### FIXED CODE ###

a,b,c=map(int,input().split())
ans=[]
ans.append(a)
ans.append(b)
ans.append(c)
ans.sort(reverse=True)
temp=""
temp+=str(ans[0])
temp+=str(ans[1])
print(int(temp)+ans[2])
import math
 A,B,C,D = map(int,input().split())
 turn = math.ceil(A/D)
 if turn*B >= C:
     print("Yes")
else:
    print("No")     

### FIXED CODE ###

import math
A,B,C,D = map(int,input().split())
turn = math.ceil(A/D)
if turn*B >= C:
    print("Yes")
else:
    print("No")
N, M = list(map(int, input().split()))
info = [list(map(int, input().split())) for i in range(N)]
info = sorted(info, key=lambda x:(x[0], x[1]), reverse=True)
#print(info)

result = 0
for j in range(len(info)):
    if info[j][0] <= M:
      #print(info[j], i)
      result += info[j][1]
      M -= 1
    if M == 0:
      break
print(result)


### FIXED CODE ###

A, B = list(map(int, input().split()))
print(max([A+B, A-B, A*B]))
s = list(map(int, input().split()))
n = s[0]
m = s[1]
ans = [0]*n
flag = 0
for i in range(m):
    s = list(map(int, input().split()))
    if ans[s[0]-1] != 0 and ans[s[0]-1] != s[1]:
        flag = 1
        break
    elif s[0] == 1 and s[1] == 0:
        flag = 1
        break
    else:
        ans[s[0]-1] = s[1]

if flag == 0:
    if ans[3-n]==0:
        ans[3-n]=1
    print(''.join(map(str, ans)))
else:
    print(-1)

### FIXED CODE ###

s = list(map(int, input().split()))
n = s[0]
m = s[1]
ans = [0]*n
flag = 0
for i in range(m):
    s = list(map(int, input().split()))
    if ans[s[0]-1] != 0 and ans[s[0]-1] != s[1]:
        flag = 1
        break
    elif s[0] == 1 and s[1] == 0 and n>=2:
        flag = 1
        break
    else:
        ans[s[0]-1] = s[1]

if flag == 0:
    if ans[0]==0 and n>=2:
        ans[0]=1
    print(''.join(map(str, ans)))
else:
    print(-1)
N,M=map(int,input().split())
A=[ list(input()) for i in range(N)]
B=[ list(input()) for i in range(M)]
ans='Yes'
for i in range(N-M+1):
    for j in range(N-M+1):
        
        for k in range(i,i+M):
            for l in range(j,j+M):
                if A[k][l]!=B[k-i][l-j]:
                    ans='No'
print(ans)


### FIXED CODE ###

A,B=input().split()
poker=['2','3','4','5','6','7','8','9','10','11','12','13','1']
if poker.index(A)<poker.index(B):
    print('Bob')
elif poker.index(A)>poker.index(B):
    print('Alice')
else:
    print('Draw')
A,B,C = map(int.input().split())
if B//A < C:
  print(B//A)
else:
  print(C)

### FIXED CODE ###

a = list(map(int,input().split()))
if a[1]//a[0] == 0:
  print(0)
elif a[1]//a[0]> a[2]:
  print(a[2])
else:
  print(a[1]//a[0])
pi=3.141592653589793238462643383279 
r=int(input())
print(r*math.pi*2)


### FIXED CODE ###

import math
r=int(input())
print(r*math.pi*2)
n,m,k = map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
if sum(al)+sum(bl)<=k:
  print(n+m)
  exit()
ans = 0
used = 0
indexa = indexb = 0
for i in range(n):
  if used+al[i] <= k:
    used += al[i]
  else:
    indexa = i
    ans += i
    break
for i in range(m):
  if used+bl[i] <= k:
    used += bl[i]
  else:
    indexb = i
    ans += i
    break

tmp = ans
for i in range(indexa-1,-1,-1):
  used -= al[i]
  tmp -= 1
  while bl[indexb]+used <=k:
    used += bl[indexb]
    indexb += 1
    tmp += 1
  ans = max(tmp,ans)
print(ans)

### FIXED CODE ###

n,m,k = map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
if sum(al)+sum(bl)<=k:
  print(n+m)
  exit()
ans = 0
used = 0
indexa = indexb = -1
for i in range(n):
  if used+al[i] <= k:
    used += al[i]
    indexa=i
    ans += 1
  else:
    break
for i in range(m):
  if used+bl[i] <= k:
    used += bl[i]
    indexb = i
    ans+=1
  else:
    break

tmp = ans
for i in range(indexa,-1,-1):
  used -= al[i]
  tmp -= 1
  while indexb<m-1 and bl[indexb+1]+used <=k:
    used += bl[indexb+1]
    indexb += 1
    tmp += 1
  ans = max(tmp,ans)
print(ans)
#!/usr/bin/env python3

import sys

n, k = map(int, input().split())
D = list(map(int, input().split()))

for i in range(1, 100):
    total = n * i
    st = set(int(x) for x in str(total))
    l = len(st)
    if len([x for x in st if x not in D]) == l:
        print(total)
        break

### FIXED CODE ###

#!/usr/bin/env python3

import sys
  
if sorted(sys.stdin.readline().split()) == ['5', '5', '7']:
  print('YES')
else:
  print('NO')
N , K = map(int, input().split())
A = list(map(int, input().split()))
syurui = set(A)
ans = 0
if len(syurui) > K:
    ans = sum(sorted([A.count(i) for i in syurui])[:n_syurui-K])
print(ans)

### FIXED CODE ###

import collections
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
hint = collections.Counter(A)
ans = 0
bb = hint.most_common()
if K >= len(bb):
    print(ans)
else:
    for i in range(-1, -(len(bb)-K)-1, -1):
        ans += bb[i][1]
    print(ans)
N = int(input())
A = (int(x) for x in input().split())
sum  = 1
for i in A:
    sum = sum * i
    if(i == 0):
        print(0)
        break
    if(sum > (10**18)):
        print(-1)
        break
    elif(len(A) == N):
        print(sum)
        break



### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
sum  = 1
flag = 0
for i in A:
    if(i == 0):
        print(0)
        flag=2
        break
if(flag==0):
    for i in A:
        sum = sum * i
        if(sum > 10**18):
            flag=1
            break
if(flag==0):
    print(sum)
elif(flag==1):
    print(-1)
import math

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

result=float(a*b//math.gcd(a,b))
print(result)

### FIXED CODE ###

from fractions import gcd
a,b=map(int,input().split())

result=int(a*b//gcd(a,b))
print(result)
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd
import sys
#input = sys.stdin.readline


"""
#import copy
from collections import *
from heapq import *
N,K=map(int,input().split())
VVV=list(map(int,input().split()))
value=0

VV=deque(VVV)
Llst=[[]]
V=VV.copy()
for i in range(min(K,N)):
    Llst.append(Llst[-1].copy())
    a=V.popleft()
    Llst[-1].append(a)

Rlst=[[]]
V=VV.copy()
for i in range(min(K,N)):
    Rlst.append(Rlst[-1].copy())
    a=V.pop()
    Rlst[-1].append(a)

#print(Llst,Rlst)
for l in range(K):
    for r in range(K-l):
        lst=Llst[l]+Rlst[r]
        lst.sort(reverse=True)
        for i in range(K-l-r):
            if lst:
                if lst[-1]<0:
                    lst.pop()
                else:
                    break
            else:
                break
        value=max(value,sum(lst))
print(value)


### FIXED CODE ###

"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd
import sys
#input = sys.stdin.readline


"""
import copy
from collections import *
from heapq import *
N,K=map(int,input().split())
VVV=list(map(int,input().split()))
value=0

VV=deque(VVV)
Llst=[[]]
V=copy.copy(VV)
for i in range(min(K,N)):
    Llst.append(copy.copy(Llst[-1]))
    a=V.popleft()
    Llst[-1].append(a)

Rlst=[[]]
V=copy.copy(VV)
for i in range(min(K,N)):
    Rlst.append(copy.copy(Rlst[-1]))
    a=V.pop()
    Rlst[-1].append(a)

#print(Llst,Rlst)
for l in range(min(K,N)+1):
    for r in range(min(K,N)+1-l):
        lst=Llst[l]+Rlst[r]
        lst.sort(reverse=True)
        for i in range(K-l-r):
            if lst:
                if lst[-1]<0:
                    lst.pop()
                else:
                    break
            else:
                break
        value=max(value,sum(lst))
print(value)
from collections import defaultdict
 
n = int(input())
raw_numbers = list(map(int, input().split()))
Q = int(input())
 
total = sum(raw_numbers)
 
numbers = defaultdict(int)
 
for num in raw_numbers:
    numbers[num] += 1

for i in range(q):
    b, c = map(int, input().split())
    taken = numbers[b]
    total -= numbers[b]*b
    numbers[c] += numbers[b]
    numbers[b] = 0
    total += taken*c
    print(total)

### FIXED CODE ###

class Counter(dict):
    def __missing__(self, i):
        return 0

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

total = sum(a)

bucket = Counter()

for item in a:
    bucket[item] += 1

for i in range(q):
    b, c = map(int, input().split())
    taken = bucket[b]
    total -= bucket[b]*b
    bucket[c] += bucket[b]
    bucket[b] = 0
    total += taken*c
    print(total)
A, op, B = input(),split()
if op = '+':
  print(A+B)
if op = '-':
  print(A-B)

### FIXED CODE ###

A, op, B = input().split()
if op is '+':
  print(int(A)+int(B))
if op is '-':
  print(int(A)-int(B))
import math
n = int(input())

count = 0

def sosu(n,z):
    for i in range(z, int(math.sqrt(n))+1):
        if n%i == 0:
            return i
            break
    return -1

if sosu(n,2) == -1 and n != 1:
    print(1)
    exit()

ans  = 0
z = 2

def hantei(n):
    i = sosu(n,2)
    s = 0
    if sosu(n,2) == -1:
        return True
    if sosu(n,2) > 0:
        s = n ** (1/i)
        if int(s) == math.floor(s):
            print(n,s)
            return True
        else:
            return False

memo = []

while(n != 1) :
    ans = sosu(n,z)
    print(n,ans,z)
    if ans == -1:
        if memo.count(n) == 0 and hantei(n):
            count +=1
            break
        else:
            break

    if hantei(ans) :
        memo.append(ans)
        z = ans+1
        n = n//ans
        count += 1
    else:
        z = ans +1
    #print(count)



print(count)


### FIXED CODE ###

n, m = map(int,input().split())
print(n*m)
import math
a=int(input())
b=float(input())
p=a*b
print(math.floor(p))

### FIXED CODE ###

A, B = input().split()
A, B = int(A), int(B.replace('.', ''))
print(A * B // 100)
n = int(input())
l = sorted(list(itertools.permutations([i for i in range(1,n+1)])))

al = tuple([int(i) for i in input().split()])
bl = tuple([int(i) for i in input().split()])


a,b = 0,0


if al == bl:
    print(0)
else:
    for idx,i in enumerate(l):
        if i == al:
            a = idx
        elif i == bl:
            b = idx
        else:
            pass
        
    print(abs(a-b))

### FIXED CODE ###

import itertools

n = int(input())
l = sorted(list(itertools.permutations([i for i in range(1,n+1)])))

al = tuple([int(i) for i in input().split()])
bl = tuple([int(i) for i in input().split()])


a,b = 0,0


if al == bl:
    print(0)
else:
    for idx,i in enumerate(l):
        if i == al:
            a = idx
        elif i == bl:
            b = idx
        else:
            pass
        
    print(abs(a-b))
n = int(input())
lt = [int(x) for x in input().split()]
if 0 in lt:
    print(0)
else:
    ans = 1 
    for x in lt:
       ans*=x 
       if ans > 10**18:
           ans=-1
print(ans)

### FIXED CODE ###

n = int(input())
lt = [int(x) for x in input().split()]
ans =0
if 0 in lt:
    ans=0
else:
    ans = 1 
    for x in lt:
        ans*=x 
        if ans > 10**18:
            ans="-1"
            break 
print(ans)
import sys
input = sys.stdin.readline

# 再帰上限を引き上げる
sys.setrecursionlimit(10**6)




n,u,v = (int(x) for x in input().split())

u,v = u-1,v-1

a = [[] for i in range(n)]

for i in range(n-1):
	# 配列indexは0開始だからinputは-1
	l,m = (int(x)-1 for x in input().split())
	a[l].append(m)
	a[m].append(l)

# v視点のdistを調べる
dist_u = [0]*n
dist_v = [0]*n

# G:graph, cr:current node, seen:is seen?, dist:out;each distance
def dfs_u(cr,seen):
	seen[cr] = 1
	for i in G[cr]: #G[cr]から行ける各頂点へ
		if seen[i] == 0: #まだ通っていなかったら
			dist_u[i] = dist_u[cr]+1
			dfs_u(i,seen)
# G:graph, cr:current node, seen:is seen?, dist:out;each distance
def dfs_v(cr,seen):
	seen[cr] = 1
	for i in G[cr]: #G[cr]から行ける各頂点へ
		if seen[i] == 0: #まだ通っていなかったら
			dist_v[i] = dist_v[cr]+1
			dfs_v(i,seen)

dfs_u(u,[0]*n)
# u視点のdistを調べる
dfs_v(v,[0]*n)

for i in range(n):
	if dist_u[i] >= dist_v[i]: # vが追いつける距離なら
		dist_u[i] = -1

print(dist_v[dist_u.index(max(dist_u))] - 1)

### FIXED CODE ###

import sys
input = sys.stdin.readline

# 再帰上限を引き上げる
sys.setrecursionlimit(10**6)

# G:graph, cr:current node, seen:is seen?, dist:out;each distance
def dfs(G,cr,seen,dist):
	seen[cr] = 1
	for i in G[cr]: #G[cr]から行ける各頂点へ
		if seen[i] == 0: #まだ通っていなかったら
			dist[i] = dist[cr]+1
			dfs(G,i,seen,dist)


n,u,v = (int(x) for x in input().split())

u,v = u-1,v-1

a = [[] for i in range(n)]

for i in range(n-1):
	# 配列indexは0開始だからinputは-1
	l,m = (int(x)-1 for x in input().split())
	a[l].append(m)
	a[m].append(l)

# v視点のdistを調べる
dist_u = [0]*n
dist_v = [0]*n

dfs(a,u,[0]*n,dist_u)
# u視点のdistを調べる
dfs(a,v,[0]*n,dist_v)

for i in range(n):
	if dist_u[i] >= dist_v[i]: # vが追いつける距離なら
		dist_v[i] = -1

print(max(dist_v) - 1)
import sys


def line(N, X, Y):
    X = X - 1
    Y = Y - 1

    queue = [(a, a) for a in range(N - 1)]
    visited = set()

    for i in range(N - 1):
        new_queue = []

        def add_to_queue(x, y):
            if y == N or y < 0:
                return
            if x == N or x < 0:
                return
            if x == y:
                return

            if x > y:
                x, y = y, x

            t = (x, y)
            if t not in visited:
                new_queue.append(t)
                visited.add(t)

        for q in queue:
            add_to_queue(q[0], q[1] + 1)
            add_to_queue(q[0], q[1] - 1)
            add_to_queue(q[0] + 1, q[1])
            add_to_queue(q[0] - 1, q[1])

            if q[1] == X:
                add_to_queue(q[0], Y)
            if q[1] == Y:
                add_to_queue(q[0], X)
            if q[0] == X:
                add_to_queue(Y, q[1])
            if q[0] == Y:
                add_to_queue(X, q[1])

        print(f"{len(new_queue)}")
        # print(f"{len(new_queue)} {new_queue}")
        queue = new_queue


N, X, Y = map(int, input().split())
line(N, X, Y)

# line(5, 2, 4)
# print()
# line(3, 1, 3)
# print()
# line(7, 3, 7)
# print()
# line(10, 4, 8)


### FIXED CODE ###

# https://atcoder.jp/contests/abc160/tasks/abc160_d
N, X, Y = map(int, input().split())

visited = set()

# special case: first advance
for i in range(N - 1):
    visited.add((i, i + 1))
visited.add((X - 1, Y - 1))

print(len(visited))

next_items = visited.copy()
for _ in range(N - 2):
    candidates = []

    for point in next_items:
        x, y = point

        if (x - 1, y) not in visited and x - 1 >= 0:
            visited.add((x - 1, y))
            candidates.append((x - 1, y))

        if (x + 1, y) not in visited and x + 1 != y:
            visited.add((x + 1, y))
            candidates.append((x + 1, y))

        if (x, y - 1) not in visited and x != y - 1:
            visited.add((x, y - 1))
            candidates.append((x, y - 1))

        if (x, y + 1) not in visited and y + 1 < N:
            visited.add((x, y + 1))
            candidates.append((x, y + 1))

    print(len(candidates))
    next_items = candidates
N = int(input())
A = list(map(int, input().split))
ans = 1

for i in range(N):
    ans = ans*A[i]

if ans >= 10**18:
    print("-1")
else:
    print(ans)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
if 0 in A:
    print(0)
    exit()
ans=1
for i in A:
    ans*=i
    if ans>10**18:
        print(-1)
        exit()
print(ans)
n=(int)(nput())
a=input().split()
for i in range(n):
  a[i]=(int)(a[i])
  
dic={}
sum=0
for i in range(n):
  if not a[i] in dic:
    dic[a[i]]=1
  else:
    dic[a[i]]+=1
    sum+=dic[a[i]]-1

for i in a:
  print(sum-dic[i]+1)



### FIXED CODE ###

n=(int)(input())
a=input().split()
for i in range(n):
  a[i]=(int)(a[i])
  
dic={}
sum=0
for i in range(n):
  if not a[i] in dic:
    dic[a[i]]=1
  else:
    dic[a[i]]+=1
    sum+=dic[a[i]]-1

for i in a:
  print(sum-dic[i]+1)
s = input()
ns = sorted(s)
ans = yes
for i in range(len(s)-1):
  if s[i] == s[i+1]:
    ans = no
print(ans)

### FIXED CODE ###

s = input()
if len(s) == len(set(s)):
  print('yes')
else :
  print('no')
n = int(input())
s = input()
print(max(len(s[:i]&s[i:] for i in range(n))))

### FIXED CODE ###

N = int(input())
S = input()
max = 0
for i in range(1, N-1):
  X = set(S[0:i])
  Y = set(S[i:N])
  if max < len(X&Y):
    max = len(X&Y)
print(max)
import sys
input=sys.stdin.readline

def ma():
    return map(int,input().split())
def main():
    n,k=ma()
    A=list(ma())
    ans=[0]*(n+1)
    now=1
    while True:
        ans[now]=1
        now=A[now-1]
        if ans[now]==1:
            use=ans.index(now)
            tool=len(ans)-use
            break 

    if use>=k:
        print(ans[k])
        exit()
    else:
        p=(k-use)%tool
        print(ans[use+p])

main()

### FIXED CODE ###

def ma():
    return map(int,input().split())
def main():
    n,k=ma()
    A=list(ma())
    ans=[]
    exp=[0]*(n+1)
    now=1
    
    while True:
        ans.append(now)
        exp[now]=1
        now=A[now-1]
        if exp[now]==1:
            use=ans.index(now)
            tool=len(ans)-use
            break 

    if use>=k:
        print(ans[k])
        exit()
    else:
        p=(k-use)%tool
        print(ans[use+p])

main()
n,k=map(int,input().split())
A=list(map(int,input().split()))
A=[0]+A
B=[]
C=[0]+[-1]*n
now_city=1
seen=set()

#【ループ回数】200000
for i in range(1,len(A)):
    now_city=A[now_city]
    #【ループ回数】B 内で now_city があるかを探索
    #if now_city in B:
    #    route=B[C[now_city]-1:i-1]
    #    break
    B.append(now_city)
    C[now_city]=i
if k <= len(B):
    print(B[k-1])
else:
    k = k- len(B)
    x = k % len(route)
    if x ==0:
        print(route[-1])
    else:
        print(route[x-1])


### FIXED CODE ###

n,k = map(int,input().split())
s = list(map(int,input().split()))
# print(s)
now_city = 1
s_l_city = 1
t = [0] #何回そこを通ったか
f = [0] #何回目にそこを通ったか
a=0
b = 0#サイクルありなし
f_l=0#ループの最初

#【ループ回数】200000
for i in range(n):
    t.append(0)
    f.append(-1)
# print(s)
sycle = 0
#【ループ回数】200000
for i in range(1,n+10):
    now_city = s[now_city-1]

    if t[now_city-1]==1:
        #  print(i,f[j])
         sycle=i-f[now_city-1]
         f_l=f[now_city-1]
        #  f_l=i
        #  a = 1
         b = i
        #  s_l_city=now_city
        #  print("ループの最初の数字",now_city,"最初は"+str(f_l)+"回目","周期は",sycle)
         break
    t[now_city-1]+=1
    f[now_city-1]=i
# print(t)
# print(f_l)
# print(f_l,sycle,s_l_city)

if k>b:
    # now_city=s_l_city
    for _ in range((k-f_l)%sycle):

        now_city = s[now_city-1]
    # print((k-f_l)%sycle)
    print(now_city)
else:
    # print("ループなし")
    now_city=1
    for _ in range(k):
        now_city=s[now_city-1]
    print(now_city)
x,y = map(int,raw_input().strip().split(' '))
follow = [[] for i in range(n)]
for i in range(y):
    h,c = map(int,raw_input().strip().split(' '))
    follow[h].append(c)
    follow[c].append(h)
 
color = {}
u = 0

for i in range(x):
    if not i in color:
        que = [i]
        color[i] = u
        while len(que) > 0:
            u = que[0]
            for v in follow[u]:
                if not v in color:
                    color[v] = u
                    que.append(v)
            del que[0]
        u += 1
 
 
q = int(raw_input())
for i in range(q):
    h,c = map(int,raw_input().strip().split(' '))
    if color[h] == color[c]:
        print 'yes'
    else:
        print 'no'

### FIXED CODE ###

x,y = map(int,raw_input().strip().split(' '))
follow = [[] for i in range(x)]
for i in range(y):
    s,t = map(int,raw_input().strip().split(' '))
    follow[s].append(t)
    follow[t].append(s)
 
color = {}
c = 0

for i in range(x):
    if not i in color:
        que = [i]
        color[i] = c
        while len(que) > 0:
            u = que[0]
            for v in follow[u]:
                if not v in color:
                    color[v] = c
                    que.append(v)
            del que[0]
        c += 1
 
 
q = int(raw_input())
for i in range(q):
    s,t = map(int,raw_input().strip().split(' '))
    if color[s] == color[t]:
        print 'yes'
    else:
        print 'no'
n = input()

S = map(int, raw_input().split())

q = input()

T = map(int, raw_input().split())

S.append(0)
cnt = 0
for i in range(q):
    left = 0
    right = n
    while left < right:
        mid = (left + right) / 2
        if S[mid] == T[j]:
            cnt = cnt + 1
        else if T[j] < S[mid]:
            right = mid
        else:
            left = mid + 1

print cnt

### FIXED CODE ###

n = input()

S = map(int, raw_input().split())

q = input()

T = map(int, raw_input().split())

cnt = 0
for j in range(q):
    left = 0
    right = n
    while left < right:
        mid = (left + right) / 2
        if S[mid] == T[j]:
            cnt = cnt + 1
            break
        elif T[j] < S[mid]:
            right = mid
        else:
            left = mid + 1

print cnt
a = map(int, input().split())
print(max(a)-min(a))

### FIXED CODE ###

a = list(map(int, input().split()))
print(max(a) - min(a))
n = int(input())
for n in range(n+1):
  num += n
print(num)


### FIXED CODE ###

N = int(input())
cnt = 0
for i in range(N+1):
    cnt += i
print(cnt)
N, K = map(int, input().split())
import math
def nCr(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
 
for j in range(K):
  if (2*j+1)>N:
    print(0)
  else:
    x = (nCr((K-1), j) * nCr(N-K+1, j+1))
    if (x > (10**9+7)):
         print(x-(10**9+7))
    else:
         print(x)

### FIXED CODE ###

N, K = map(int, input().split())
from operator import mul
from functools import reduce
 
def nCr(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
 
for j in range(K):
  if (K+j)>N:
    print(0)
  else:
    x = (nCr((K-1), j) * nCr(N-K+1, j+1))
    if (x > (10**9+7)):
         print(x%(10**9+7))
    else:
         print(x)
import sys

def insertionSort( nums, n, g ):
	cnt = 0
	i = g
	while i < n:
		v = nums[i]
		j = i - g
		while 0 <= j and v < nums[j]:
			nums[ j+g ] = nums[j]
			j -= g
			cnt += 1
		nums[ j+g ] = v
		i += 1
	return cnt
		
def shellSort( nums, n ):
	g = []
	val = 1
	while val <= n:
		g.append( val )
		val = 3*val+1
	
	g.reverse( )
	m = len( g )
	print( m )
	print( " ".join( map( str, g ) ) )
	cnt = 0
	for i in range( m ):
		cnt += insertionSort( nums, n, g[i] )
	print( cnt )
    
n = int( sys.stdin.readline( ) )
nums = []
for i in range( n ):
	nums.append( int( sys.stdin.readline( ) ) )

shellSort( nums, n )
print( "\n".join( map( str, nums ) ) )

### FIXED CODE ###

import sys
 
def insertionSort( nums, n, g ):
    cnt = 0
    i = g
    while i < n:
        v = nums[i]
        j = i - g
        while 0 <= j and v < nums[j]:
            nums[ j+g ] = nums[j]
            j -= g
            cnt += 1
        nums[ j+g ] = v
        i += 1
    return cnt
         
def shellSort( nums, n ):
    g = []
    val = 1
    while val <= n:
        g.append( val )
        val = 3*val+1
     
    g.reverse( )
    m = len( g )
    print( m )
    print( " ".join( map( str, g ) ) )
    cnt = 0
    for i in range( m ):
        cnt += insertionSort( nums, n, g[i] )
    print( cnt )
     
n = int( sys.stdin.readline( ) )
nums = []
for i in range( n ):
    nums.append( int( sys.stdin.readline( ) ) )
 
shellSort( nums, n )
print( "\n".join( map( str, nums ) ) )