Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys

def main():
    n = int(input())
    a = tuple(map(int,sys.stdin.readline().split()))
    for cnt in range(len(a)):
        num = 0
        for j in a[cnt:]:
            if j == cnt + 1:
                num += 1
        print(num)
    print(0)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import collections
N = int(input())
A = list(map(int, input().split()))
count = collections.Counter(A)
for n in range(N):
  print(count[n+1])
### BUGGY CODE ###

S = input()
Q = int(input())
Flag = True

for i in range(Q):
    Query = input()
    if Query[0] == "1":
        Flag = not Flag
    else:
        QueryList = Query.split()
        if Flag:
            if QueryList[1] =="1":
                S = QueryList[2]+S
            else:
                S = S+QueryList[2]
        else:
            inv_add = QueryList[2][::-1]
            if QueryList[1] =="2":
                S = QueryList[2]+S
            else:
                S = S+QueryList[2]

if Flag:
    print(S)
else:print(S[::-1])

### FIXED CODE ###

from collections import deque

d = deque()
S = input()
d.append(S)
Q = int(input())
Flag = True
 
for i in range(Q):
    Query = input()
    if Query[0] == "1":
        Flag = not Flag
    else:
        QueryList = Query.split()
        if Flag:
            if QueryList[1] =="1":
                d.appendleft(QueryList[2])
            else:
                d.append(QueryList[2])
        else:
            if QueryList[1] =="2":
                d.appendleft(QueryList[2])
            else:
                d.append(QueryList[2])

d_string = "".join(list(d))

if not Flag:
    d_string = d_string[::-1]    
print(d_string)
### BUGGY CODE ###

S = input()
MOD = 10**9 + 7


def main():
    DP = [0] * 13
    n = len(S)
    if S[-1] == '?':
        for i in range(10):
            DP[i] = 1
    else:
        DP[int(S[-1])] = 1

    for i in range(1, n):
        preDP = DP
        DP = [0] * 13
        if S[-i-1] == '?':
            for x in range(10):
                nx = x * 10 ** i
                for k in range(13):
                    t = (nx + k) % 13
                    DP[t] += preDP[k]
                    DP[t] %= MOD
        else:
            y = int(S[-i-1]) * 10 ** i
            for k in range(13):
                t = (y+k) % 13
                DP[t] = preDP[k] % MOD
    ans = DP[5]
    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
MOD = 10**9 + 7


def main():
    S = input().rstrip()
    DP = [0] * 13
    n = len(S)
    DP[0] = 1

    for i in range(0, n):
        preDP = DP
        DP = [0] * 13
        if S[i] == '?':
            for k in range(13):
                for x in range(10):
                    t = (x + 10*k) % 13
                    DP[t] += preDP[k]
                    DP[t] %= MOD
        else:
            y = int(S[i])
            for k in range(13):
                t = (y+10*k) % 13
                DP[t] += preDP[k]
                DP[t] %= MOD

    ans = DP[5]
    print(ans)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

a=int(input())
ai=[int(i) for i in input().split()]

c=[ai.count(x) for x in set(ai) if ai.count(x)>1]
val=sum([x*(x-1)//2 for x in c])
for i in ai:
    b=ai.count(i)
    print(val-b+1)

### FIXED CODE ###

import collections
a=int(input())
ai = list(map(int, input().split()))
c = collections.Counter(ai)
val=0
for i in c.values():
    val+=i*(i-1)//2
for i in range(len(ai)):
    b=c[ai[i]]
    print(val-b+1)
### BUGGY CODE ###

from operator import itemgetter
import collections
N = int(input())

X = list(map(int, input().split()))
d = {} 
for x in X:
  if x in d:
    d[x] += 1
  else:
    d[x] = 1
    
for x in X:
  idx = N//2
  d[x] -= 1
  for k in sorted(d.keys(), reverse = True):
    idx -= d[k]
    if idx <= 0:
      print(k)
      break
  d[x] += 1

### FIXED CODE ###

N = int(input())
X = list(map(int,input().split()))
SX = sorted(X)
m1,m2 = SX[N//2-1],SX[N//2]

for a in X:
    print(m2 if a <= m1 else m1)
### BUGGY CODE ###

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

for i in range(2,n):
    c = float("inf")
    for j in range(1,min(k,i)+1):
        c = min(c,dp[i-j] + abs(a[i] -a[i-j]))
    dp[i] = c
print(dp[n-1])

### FIXED CODE ###

n,k = map(int, input().split())
l = list(map(int,input().split()))
dp = [0]*n
dp[1] = abs(l[1] - l[0])

for i in range(2,n):
    c = float("inf")
    #1個前から飛んでく、2個前から、、、k個前から飛んでくる最小のコストを求める
    for j in range(min(k,i)):
        c = min(dp[i-(j+1)]+abs(l[i]-l[i-(j+1)]),c)
    dp[i] = c
print(dp[n-1])
### BUGGY CODE ###

def main():
    s = input()
    q = int(input())
    r = 1
    for _ in range(q):
        n, *fc = input().split()
        if n == "1":
            r *= -1
        else:
            f, c = fc
            f = 1 if f == "1" else -1
            if f*r == 1:
                s = c+s
            else:
                s = s+c
    print(s[::r])
                
            

if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import deque
def main():
    s = deque(list(input()))
    q = int(input())
    r = 1
    for _ in range(q):
        n, *fc = input().split()
        if n == "1":
            r *= -1
        else:
            f, c = fc
            f = 1 if f == "1" else -1
            if f*r == 1:
                s.appendleft(c)
            else:
                s.append(c)
    print("".join(list(s)[::r]))

if __name__ == "__main__":
    main()
### BUGGY CODE ###

input()
L = [int(i) for i in input().split()]
cnt,ans = 0,1
for i in sorted(set(L),reverse=True):
  if L.count(i)>=4 and cnt==0:
    ans = i*i
    break
  elif 2<=L.count(i)<4:
    ans *= i
    cnt += 1
    if cnt == 2:
      break
  elif L.count(i)>=4 and cnt==1:
    ans *=i
    break
print(0 if ans==1 else ans)

### FIXED CODE ###

from collections import defaultdict
N = int(input())
A = [int(i) for i in input().split()]
d = defaultdict(int)
for a in A:
  d[a] += 1
x = 1
cnt = 0
d = sorted(d.items(), key=lambda x:-x[0])
for i, j in d:
  if x == 1 and j >= 4:
    print(i**2)
    exit()
  if j >= 2:
    x *= i
    cnt += 1
    if cnt == 2:
      break
if cnt >= 1:
  print(x)
else:
  print(0)
### BUGGY CODE ###

from collections import defaultdict, deque
n, m = map(int, input().split())
From = defaultdict(list)
To = defaultdict(bool)

for i in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    From[y].append(x)
    To[x] = True


q = deque()
for i in range(n):
    if not To[i]:
        q.append((i, 1))

dist = [0]*n

while q != deque():
    p, cnt = q.popleft()
    for t in From[p]:
        q.append((t, cnt+1))
        dist[t] = max(dist[t], cnt)

print(max(dist))


### FIXED CODE ###

from collections import defaultdict,deque

N,M=map(int,input().split())
Out=defaultdict(list)
In=defaultdict(int)

for i in range(M):
    x,y=map(int,input().split())
    Out[x].append(y)
    In[y]+=1

q=deque(v for v in range(1,N+1) if In[v]==0)

dp=[0]*(N+1)

while q:
    From = q.popleft()
    for to in Out[From]:
        dp[to]=max(dp[From]+1,dp[to])
        In[to]-=1
        if In[to]==0:
            q.append(to)
print(max(dp))
### BUGGY CODE ###

import sys
t = sys.stdin.readlines()
N,K = map(int, t[0].split())
S = []
for i in range(K):
    L,R = map(int, t[1+i].split())
    S += [ j for j in range(L,R+1)]

S = sorted(S)

step = [0]*(N+1)
step[1] = 1


for j in range(1,N):
    for s in S:
        if j + s > N or step[j] == 0:
            continue
        step[j+s] += step[j]
        step[j+s] %= 998244353
    
print(step[N])

### FIXED CODE ###

mod = 998244353
n, k = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(k)]
for i in range(k):
    lr[i][1] += 1

dp = [0]*n
dp[0] = 1
for i in range(1,n):
    dp[i] = dp[i-1]
    if i == 1:
        dp[1] = 0
    for l,r in lr:
        if i - l >= 0:
            dp[i] += dp[i-l]
        if i - r >= 0:
            dp[i] -= dp[i-r]
        dp[i] %= mod
print(dp[n-1])
### BUGGY CODE ###

N = int(input())
A = [int(i) for i in input().split()] + [1]

# 一個前の提出は嘘解法だったてへぺろ
# 桁上げの処理はpopのときにまとめてやれば良い
def check(m) :
  rl = [[0, A[0]]]
  for i in range(1, N + 1) :
    if A[i-1] < A[i] :
      rl.append([0, A[i] - A[i-1]])

    else :
      cnt = A[i-1]
      while A[i] <= cnt :
        char, size = rl.pop()
        cnt -= size
        if char >= m and size > 1 :
          if size > 2 :
            rl.append([char, size - 2])
            cnt += size - 2
          rl.append([char + char // m, 1])
          cnt += 1
        elif char >= m and size == 1 :
          if len(rl) == 0 : 
            return False
          c, s = rl.pop()
          if s > 1 :
            rl.append([c, s - 1])
          rl.append([c + char // m, 1])
        
      if A[i] - cnt - 1 >= 1 :
        rl.append([char % m, A[i] - cnt - 1])
      rl.append([char % m + 1, 1])
      cnt = A[i]
  return True
  
ng, ok = 0, N
    
while ok - ng > 1 :
  m = (ok + ng) // 2
  
  if check(m) :
    ok = m
  else :
    ng = m
    
print(ok)

### FIXED CODE ###

N = int(input())
A = [int(i) - 1 for i in input().split()]

def check(m) :
  dp = [0] * 40
  for i in range(1, N) :
    if A[i] <= A[i-1] and A[i] < 40 :
      for j in range(A[i] + 1, 40) :
        dp[j] = 0
      dp[A[i]] += 1
      for j in range(A[i], 0, -1) :
        if dp[j] >= m :
          dp[j-1] += 1
          dp[j] %= m
      if dp[0] >= m :
        return False
        
  return True

ng, ok = 0, N
for i in range(1, N) :
  if A[i] <= A[i-1] :
    ng = 1
    
while ok - ng > 1 :
  m = (ok + ng) // 2
  
  if check(m) :
    ok = m
  else :
    ng = m
    
print(ok)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n,q=map(int,input().split())
s=input()
Q=[input().rsplit() for _ in range(q)]
l,r=-1,n
while r-l>1:
	c=m=(l+r)//2
	for t,d in Q:
		if s[c]==t:
			c+= 1 if d=="R" else -1
			if c==-1 or c==n:
				break
	if c==-1:l=m
	else:r=m
a=l
l,r=-1,n
while r-l>1:
	c=m=(l+r)//2
	for t,d in Q:
		if s[c]==t:
			c+= 1 if d=="R" else -1
			if c==-1 or c==n:
				break
	if c==n:r=m
	else:l=m
b=r
print(0 if b<=a else b-a-1)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n,q=map(int,input().split())
s=input()
Q=[input().rsplit() for _ in range(q)]
l,r=-1,n
while r-l>1:
	c=m=(l+r)//2
	for t,d in Q:
		if s[c]==t:
			c+= 1 if d=="R" else -1
			if c==-1 or c==n:
				break
	if c==-1:l=m
	else:r=m
a=l
l,r=-1,n
while r-l>1:
	c=m=(l+r)//2
	for t,d in Q:
		if s[c]==t:
			c+= 1 if d=="R" else -1
			if c==-1 or c==n:
				break
	if c==n:r=m
	else:l=m
b=r
print(0 if b<=a else b-a-1)
### BUGGY CODE ###

N,X,M = map(int,input().split())
R = [X]
m = min(N,M)
for i in range(m):
    r = R[-1]
    r = r**2%M
    if r in R:
        break
    R.append(r)
for i in range(len(R)):
    if r == R[i]:
        break
a = 0
b = sum(R)
for j in range(i):
    a += R[j]
    b -= R[j]
n = len(R) - i
t = N - i
p = t // n
q = t % n
c = 0
for j in range(q):
    c += R[i+j]
ans = a + b*p + c
print(ans)

### FIXED CODE ###

N,X,M = map(int,input().split())
R = [X]
dr = {}
for i in range(M):
    dr[i] = 0
m = min(N,M)
for i in range(m):
    r = R[-1]
    r = r**2%M
    if dr[r] == 1:
        break
    R.append(r)
    dr[r] = 1
for i in range(len(R)):
    if r == R[i]:
        break
a = 0
b = sum(R)
for j in range(i):
    a += R[j]
    b -= R[j]
n = len(R) - i
t = N - i
p = t // n
q = t % n
c = 0
for j in range(q):
    c += R[i+j]
ans = a + b*p + c
print(ans)
### BUGGY CODE ###


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

sortedx = x[:]
sortedx.sort()

for i in range(n):
    ix = sortedx.index(x[i])
    #print(sortedx)
    #print(ix)
    if ix < n/2:
        print(sortedx[n//2])
    else:
        print(sortedx[n//2-1])

### FIXED CODE ###

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

sortedx = x[:]
sortedx.sort()

for i in range(n):
    #ix = sortedx.index(x[i])
    #print(sortedx)
    #print(ix)
    if x[i] <= sortedx[n//2-1]:
        print(sortedx[n//2])
    else:
        print(sortedx[n//2-1])
### BUGGY CODE ###

from itertools import permutations
N, M, X = map(int, input().split())
books = []
for _ in range(N):
    books.append(list(map(int, input().split())))
P = permutations(books, len(books))
ans = 10 ** 9 + 1
for items in P:
    price = 0
    chk = [0] * M
    for p in items:
        price += p[0]
        for i, item in enumerate(p[1:]):
            chk[i] += item
        if all(c >= X for c in chk):
            ans = min(ans, price)
            break

if ans == 10 ** 9 + 1:
    ans = -1
print(ans)

### FIXED CODE ###

from itertools import combinations
N, M, X = map(int, input().split())
books = []
for _ in range(N):
    books.append(list(map(int, input().split())))
P = []
for i in range(1, N+1):
    for item in list(combinations(books, i)):
        P.append(item)
ans = 10 ** 9 + 1
for items in P:
    price = 0
    chk = [0] * M
    for p in items:
        price += p[0]
        for i, item in enumerate(p[1:]):
            chk[i] += item
        if all(c >= X for c in chk):
            ans = min(ans, price)
            break
if ans == 10 ** 9 + 1:
    ans = -1
print(ans)
### BUGGY CODE ###

def main():
    n = int(input())
    a = [int(_) for _ in input().split()]

    order = []

    for i in range(n):
        order.append(a.index(i+1) + 1)

    print(*order)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n = int(input())
    a = [int(_) for _ in input().split()]

    order = [0 for i in range(n)]

    for i in range(n):
        order[a[i] - 1] = i + 1


#        order.append(a.index(i+1) + 1)

    print(*order)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import numpy as np

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

if np.all(a>=b):
  print(0)
elif np.sum(a)<np.sum(b):
  print(-1)
else:
  temp_a = a[a-b<0]
  temp_b = b[a-b<0]
  sum_a = np.sum(temp_a)
  sum_b = np.sum(temp_b)
  ans = len(temp_a)

  if sum_a>=sum_b:
    print(ans)
  else:
    aa = a[a-b>=0]
    bb = b[a-b>=0]
    for _ in range(n-ans):
      index = np.argmax(aa-bb)
      sum_a += aa[index]
      sum_b += bb[index]
      ans += 1
      if sum_a>=sum_b:
        print(ans)
        exit()
      else:
        aa[index]=0
        bb[index]=0
        continue

### FIXED CODE ###

import sys
 
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
 
import numpy as np
 
N = int(readline())
A = np.array(readline().split(), dtype=np.int64)
B = np.array(readline().split(), dtype=np.int64)
 
diff = A-B
lack = -diff[diff<0]
remain = diff[diff>0]
 
x = lack.sum()
remain.sort()
cum = remain[::-1].cumsum()
 
y = 0 if x == 0 else np.searchsorted(cum,x) + 1
 
answer = len(lack) + y if y <= len(remain) else -1
print(answer)
### BUGGY CODE ###

N = int(input())
p = 1
for i in range(1,N+1):
    p *= i 

print(p % (10**9 +7))


### FIXED CODE ###

N = int(input())
p = 1
big_num = 10**9+7
for i in range(1,N+1):
    p *= i 
    p %= big_num

print(p)
### BUGGY CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[float('inf')]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
  for j in range(k):
    dp[i]=min(dp[max(0,i-j-1)]+abs(h[i]-h[max(0,i-j-1)]),dp[i])
print(dp[n-1])

### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[float('inf')]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
  for j in range(k):
    dp[i]=min(dp[max(0,i-j-1)]+abs(h[i]-h[max(0,i-j-1)]),dp[i])
print(dp[n-1])
### BUGGY CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
for i in range(n):
    b = a.copy()
    b.pop(i)
    print(max(b))

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
b = a.copy()
b.sort()
a_max = b[-1]
a_second = b[-2]
for i in range(n):
    if a[i] == a_max:
        print(a_second)
    else:
        print(a_max)
### BUGGY CODE ###

H,W,N=map(int,input().split())
data=[[0 for i in range(W-2)] for j in range(H-2)]
def check(a,b):
    if a>1 and b>1:
        data[a-2][b-2]+=1
    if a>1 and b>0 and b<W-1:
        data[a-2][b-1]+=1
    if a>1 and b<W-2:
        data[a-2][b]+=1
    if a>0 and a<H-1 and b>1:
        data[a-1][b-2]+=1
    if a>0 and a<H-1 and b>0 and b<W-1:
        data[a-1][b-1]+=1
    if a>0 and a<H-1 and b<W-2:
        data[a-1][b]+=1
    if a<H-2 and b>1:
        data[a][b-2]+=1
    if a<H-2 and b>0 and b<W-1:
        data[a][b-1]+=1
    if a<H-2 and b<W-2:
        data[a][b]+=1
    return
for k in range(N):
    a,b=map(int,input().split())
    a-=1
    b-=1
    check(a,b)
for i in range(10):
    count=0
    for j in range(len(data)):
        count+=data[j].count(i)
    print(count)

### FIXED CODE ###

from collections import defaultdict
H,W,N=map(int,input().split())
ans=[0 for i in range(10)]

data=defaultdict(int)
def check(a,b):
    if a>0 and a<H-1 and b>0 and b<W-1:return True
    else:return False

def count(a,b):
    for i in range(a-2,a+1):
        for j in range(b-2,b+1):
            if check(i,j):
                x=(i,j)
                data[x]+=1
                
for k in range(N):
    a,b=map(int,input().split())
    count(a,b)

for v in data.values():
    ans[v]+=1

ans[0]=(H-2)*(W-2)-sum(ans[1:])
for i in range(10):
    print(ans[i])
    
#http://arc061.contest.atcoder.jp/data/arc/061/editorial.pdf
#https://atcoder.jp/contests/abc045/submissions/4024831
#https://atcoder.jp/contests/abc045/submissions/4017890
### BUGGY CODE ###

def match(x, y):
    return x == y or x == '?' or y == '?'


def check(s, t):
    ANS = [1] * (10 ** 5)
    S = len(s); T = len(t)
    for i in range(S):
        for j in range(T):
            if not match(s[i], t[j]):
                ANS[i - j + 50000] = 0
    return ANS


a = input()
b = input()
c = input()
lenA = len(a)
lenB = len(b)
lenC = len(c)

AB = check(a, b)
AC = check(a, c)
BC = check(b, c)

ans = lenA + lenB + lenC
M = ans
for i in range(-2 * M, 2 * M + 1):
    for j in range(-2 * M, 2 * M + 1):
        if AB[i + 50000] and AC[j + 50000] and BC[j - i + 50000]:
            L = min(0, min(i, j))
            R = max(lenA, max(lenB + i, lenC + j))
            ans = min(ans, R - L)

print(ans)


### FIXED CODE ###

def match(x, y):
    return x == y or x == '?' or y == '?'


def check(s, t):
    ANS = [1] * (10 ** 5)
    S = len(s); T = len(t)
    for i in range(S):
        for j in range(T):
            if not match(s[i], t[j]):
                ANS[i - j + 50000] = 0
    return ANS


def solve(a, b, c):
    lenA = len(a)
    lenB = len(b)
    lenC = len(c)

    AB = check(a, b)
    AC = check(a, c)
    BC = check(b, c)

    ans = lenA + lenB + lenC
    for i in range(-lenB, lenA + lenB + 1):
        for j in range(-lenC, lenA + lenC + 1):
            if AB[i + 50000] and AC[j + 50000] and BC[j - i + 50000]:
                L = min(0, min(i, j))
                R = max(lenA, max(lenB + i, lenC + j))
                ans = min(ans, R - L)

    return ans


a = input()
b = input()
c = input()


ans = min(solve(a, b, c), min(solve(b, c, a), solve(c, a, b)))

print(ans)
### BUGGY CODE ###

from heapq import heappop, heappush

N, K = map(int, input().split())
sushi = []
for _ in range(N):
    t, d = map(int, input().split())
    heappush(sushi, (-d, t))

maxs = []
rems = []
kinds = set()
for _ in range(K):
    d, t = heappop(sushi)
    if t in kinds:
        heappush(rems, -d)
    else:
        maxs.append(-d)
        kinds.add(t)
ans = sum(maxs) + sum(rems) + len(kinds)**2

while True:
    if not sushi or not rems:
        break
    d, t = heappop(sushi)
    if t in kinds:
        continue
    else:
        heappop(rems)
        maxs.append(-d)
        kinds.add(t)
        ans = max(ans, sum(maxs) + sum(rems) + len(kinds)**2)

print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(N)]
sushi.sort(key=lambda x: x[1], reverse=True)

score = 0

remains = []
kinds = set()
for t, d in sushi[:K]:
    if t in kinds:
        remains.append(d)
    kinds.add(t)
    score += d
score += len(kinds)**2

test = score
for t, d in sushi[K:]:
    if not remains:
        break
    if t in kinds:
        continue
    kinds.add(t)
    rm = remains.pop()
    test = test + (d - rm) + (len(kinds)*2 - 1)
    score = max(score, test)

print(score)
### BUGGY CODE ###

K = int(input())

def gcd(a, b):
    if a == 0 or b == 0:
        return max(a,b)
    x, y = min(a,b), max(a,b)
    return gcd(x,y%x )

ans = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        x = gcd(a,b)
        for c in range(1, K+1):
            ans += gcd(x,c)
print(ans)


### FIXED CODE ###

K = int(input())

def gcd(a, b):
    if a == 0 or b == 0:
        return max(a,b)
    x, y = min(a,b), max(a,b)
    return gcd(x,y%x )

ans = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        x = gcd(a,b)
        for c in range(1, K+1):
            ans += gcd(x,c)
print(ans)
### BUGGY CODE ###

import functools
import operator
f = functools.partial(functools.reduce, operator.mul)
n = int(input())
a = list(map(int,input().split()))
ans = f(a)

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

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
if a[n-1] == 0:
    print("0")
    exit()
ans = 1
for i in a:
    ans *= i
    if ans > 10 ** 18:
        ans = -1
        break
print(ans)
### BUGGY CODE ###

a = int(input())
b = list(map(int, input().split()))
for i in range(1,a):
    n = b.count(i)
    print(n)
    if n>0:
        b = [j for j in b if i != j]
print(0)

### FIXED CODE ###

def main():
    a = int(input())
    b = list(map(int, input().split()))
    c = [0]*a
    for i in b:
        c[i-1] += 1
    for j in c:
        print(j)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

x,y=map(int,input().split())
if (x+y)%3!=0:
    print(0)
else:
    a=y-(x+y)//3
    b=x-(x+y)//3
    if a<0 or b<0:
        print(0)
    else:
        p=1000000007
        def comb(n,k,p):
            from math import factorial
            if n<0 or k<0 or n<k:
                return 0
            if n==0 or k==0:
                return 1
            a=factorial(n)%p
            b=factorial(k)%p
            c=factorial(n-k)%p
            return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p 
        def power_func(a,b,p):
            if b==0:
                return 1
            if b%2==0:
                d=power_func(a,b//2,p)
                return d*d %p
            if b%2==1:
                return (a*power_func(a,b-1,p))%p
        ans=comb(a+b,a,p)
        print(ans)

### FIXED CODE ###

x,y=map(int,input().split())
if (x+y)%3!=0:
    print(0)
else:
    a=y-(x+y)//3
    b=x-(x+y)//3
    if a<0 or b<0:
        print(0)
    else:
        def cmb(n, r, mod):
            if ( r<0 or r>n ):
                return 0
            r = min(r, n-r)
            return g1[n] * g2[r] * g2[n-r] % mod
        mod = 10**9+7
        N = 10**6
        g1 = [1,1]
        g2 = [1,1]
        inverse = [0, 1]
        for i in range( 2, N + 1 ):
            g1.append( ( g1[-1] * i ) % mod )
            inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
            g2.append( (g2[-1] * inverse[-1]) % mod )
        ans=cmb(a+b,a,mod)
        print(ans)
### BUGGY CODE ###

k = int(input())

if k % 2 == 0:
  print("-1")
  quit()

num = 1
cnt = 1
if k % 7 ==0:
  k = k//7

while True:
  num = num % k
  if num == 0:
    print(cnt)
    break
  else:
    num += pow(10, cnt, k)
    cnt += 1
  

### FIXED CODE ###

def main(k):
  if k % 2 == 0:
    return -1

  num = 1
  cnt = 1
  if k % 7 == 0:
    k = k//7

  for i in range(1000000):
    num = num % k
    if num == 0:
      return cnt
    else:
      num += pow(10, cnt, k)
      cnt += 1
  return -1

k = int(input())
print(main(k))