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

import heapq


n, m, s = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]
change = [list(map(int, input().split())) for i in range(n)]
INF = 10 ** 18

graph = [[] for i in range(n)]
for u, v, cost, time in info:
    u -= 1
    v -= 1
    graph[u].append((v, cost, time))
    graph[v].append((u, cost, time))
    
dist = [[INF] * 5051 for i in range(n)]
dist[0][min(s, 5050)] = 0

q = [(0, min(s, 5050), 0)] # q = [(時間, 銀貨, 現在地)]
while q:
    d, gin, v = heapq.heappop(q)
    if dist[v][gin] < d:
        continue
    tmp = gin
    cc, dd = change[v]
    while True:
        if tmp + cc <= 5050:
            dist[v][tmp + cc] = min(dist[v][tmp + cc],  dist[v][tmp] + dd)
            tmp += cc
        else:
            break

    for nxt_v, cost, time in graph[v]:
        for g in range(5051):
            if g - cost < 0:
                continue
            if dist[v][g] + time < dist[nxt_v][g - cost]:
                dist[nxt_v][g - cost] = dist[v][g] + time
                heapq.heappush(q, (dist[nxt_v][g - cost], g - cost, nxt_v))

for i in range(1, n):
     print(min(dist[i]))

### FIXED CODE ###

import heapq


n, m, s = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]
change = [list(map(int, input().split())) for i in range(n)]
INF = 10 ** 18
MAX_ = 2600

graph = [[] for i in range(n)]
for u, v, cost, time in info:
    u -= 1
    v -= 1
    graph[u].append((v, cost, time))
    graph[v].append((u, cost, time))


dist = [INF] * ((MAX_ + 1) * n)
dist[min(s, MAX_)] = 0

q = [(0, min(s, MAX_), 0)] # q = [(時間, 銀貨, 現在地)]
while q:
    d, gin, v = heapq.heappop(q)

    if dist[v * (MAX_ + 1) + gin] < d:
        continue

    cc, dd = change[v]
    tmp = gin
    r = [gin]
    while True:
        if tmp + cc <= MAX_:
            if dist[v * (MAX_ + 1) + tmp + cc] > dist[v * (MAX_ + 1) + tmp] + dd:
                dist[v * (MAX_ + 1) + tmp + cc] = dist[v * (MAX_ + 1) + tmp] + dd
                r.append(tmp)
            else:
                break
            tmp += cc
        else:
            break

    for nxt_v, cost, time in graph[v]:
        for g in r:
            if g - cost < 0:
                continue
            if dist[v * (MAX_ + 1) + g] + time < dist[nxt_v * (MAX_ + 1) + g - cost]:
                dist[nxt_v * (MAX_ + 1) + g - cost] = dist[v * (MAX_ + 1) + g] + time
                heapq.heappush(q, (dist[nxt_v * (MAX_ + 1) + g - cost], g - cost, nxt_v))

for i in range(1, n):
     print(min(dist[i * (MAX_ + 1):(i + 1) * (MAX_ + 1)]))
### BUGGY CODE ###

n = int(input())
l = sorted(list(map(int,input().split())))
l1 = set(l)
m= 0
for i in l1:
  c = l.count(i)
  if i+1 in l1:
    c += l.count(i+1)
  if i-1 in l1:
    c += l.count(i-1)
  m = max(m,c)
print(m)
  

### FIXED CODE ###

n = int(input())
a = [0]*(10**5)
l = list(map(int,input().split()))
for i in l:
  a[i]+= 1
m = 0 
for i in range(10**5-2):
  m = max(m,sum(a[i:i+3]))
print(m)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
l = []
ans = 0
for i in range(n):
  x = i + 1
  y = a[i]
  p = [x, y]
  p.sort()
  if p in l:
    ans += 1
  else:
    l.append(p)
print(ans)

### FIXED CODE ###

import collections
n = int(input())
a = list(map(int, input().split()))
d = {}
ans = 0
for i in range(n):
  d[i + 1] = a[i]
for i in range(n):
  if d[d[i + 1]] == i + 1:
    ans += 1
ans //= 2
print(ans)
### BUGGY CODE ###

S = input()
L = len(S)

res = 0
for i in range(L-3):
    for j in range(i+3, L):
        if not int(S[i:j+1])%2019:
            res += 1
print(res)

### FIXED CODE ###

# https://atcoder.jp/contests/abc164/tasks/abc164_d

from operator import mul
from functools import reduce
from collections import defaultdict

def combination(n, r):
    if not 0 <= r <= n: return 0
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

S = input()

res = 0

T = [0]
x = 0
L = len(S)
for i, s in zip(range(L),reversed(S)):
    """ 累積和 """
    x = (int(s)*pow(10,i,2019) + x)%2019
    T.append(x)

reminder = [0]*2019
for i in range(L+1):
    reminder[T[i]%2019] += 1

for c in reminder:
    res += combination(c,2)

print(res)
### BUGGY CODE ###

import itertools
n,k = map(int,input().split())
p = list(map(int,input().split()))
lstp = []
for i in range(n-k+1):
    lstp.append(p[i:i+k])
l = [0]*len(lstp)
for i in range(len(lstp)):
    for j in range(k):
        num  = 0.5*(lstp[i][j]+1)
        l[i] += num
print("{:.10f}".format(max(l)))

### FIXED CODE ###

n,k = map(int,input().split())
p = list(map(int,input().split()))
wa = sum(p[0:k])
next_wa = wa
for i in range(n-k):
    next_wa = next_wa - p[i] + p[i+k]
    if  next_wa > wa:
        wa = next_wa
print(0.5*(wa+k))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(2147483647)

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

def calc(k,i,j):
    c1 = 0
    c2 = 0
    global N,M,K,A,B
    if N-1>=i and A[i]+k <= K:
        c1 = 1+calc(A[i]+k,i+1,j)
    if M-1>=j and B[j]+k <= K:
        c2 = 1+calc(B[j]+k,i,j+1)
    return max(c1,c2)
count = calc(0,0,0)
print(count)



### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)

N, M, K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
Asum = [0]
Bsum = [0]
count = 0
for p in A:
    count += p
    Asum.append(count)
count = 0
for p in B:
    count += p
    Bsum.append(count)
best = 0
Blast = M
for t in range(N+1):
    if Asum[t] > K:
        break
    if best < t:
        best=t
    for s in reversed(range(0,Blast+1)):
        if Asum[t]+Bsum[s]<=K:
            if best < t+s:
                best=t+s
            Blast = s
            break
print(best)
### BUGGY CODE ###

import sys
input=sys.stdin.readline

from functools import lru_cache
from collections import deque
@lru_cache()
def dfs(i,j):
    q = deque()
    q.append((i, j, 0))

    d = [(1, 0), (0, 1), (-1, 0), (0, -1)]
    cnt = 1

    while q:
        x, y, num = q.pop()
        if num == 0:
            for i in range(1,5):
                dx, dy = d[i-1]
                nx = x + dx
                ny = y + dy
                if not(0 <= nx < h and 0 <= ny < w):continue
                if s[nx][ny] == '#':continue
                q.append((nx, ny, i))
                cnt += 1

        else:
            nx = x + d[num-1][0]
            ny = y + d[num-1][1]
            if not(0 <= nx < h and 0 <= ny < w):continue
            if s[nx][ny] == '#':continue
            q.append((nx, ny, num))
            cnt += 1

    return cnt

h,w = map(int, input().split())
s = [list(input()) for i in range(h)]

ans = 0
for i in range(h):
    for j in range(w):
        if ans == h + w -1:
            print(ans)
            exit()

        if s[i][j] == '#':continue
        temp = dfs(i, j)
        #print(temp,(i,j))
        if temp > ans:ans = temp

print(ans)

### FIXED CODE ###

h, w = map(int,input().split())
s = [list(input()) for i in range(h)]

L = [[0] * w for i in range(h)]
R = [[0] * w for i in range(h)]
D = [[0] * w for i in range(h)]
U = [[0] * w for i in range(h)]
for i in range(h):
    for j in range(w):
        if j == 0:
            if s[i][j] == '.':
                L[i][j] = 1
            if s[i][- (j + 1)] =='.':
                R[i][- (j + 1)] = 1

        if j != 0:
            if s[i][j] == '.':
                L[i][j] = L[i][j - 1] + 1
            if s[i][- (j + 1)] == '.':
                R[i][- (j + 1)] = R[i][- (j + 1) + 1] + 1

        if i == 0:
            if s[i][j] == '.':
                U[i][j] = 1
            if s[- (i + 1)][j] == '.':
                D[- (i + 1)][j] = 1
        if i != 0:
            if s[i][j] == '.':
                U[i][j] = U[i - 1][j] + 1
            if s[- (i + 1)][j] == '.':
                D[- (i + 1)][j] = D[- (i + 1) + 1][j] + 1
ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':continue
        temp = R[i][j] + L[i][j] + D[i][j] + U[i][j] -3
        if ans < temp:ans = temp
        #print(temp)
print(ans)
### BUGGY CODE ###

h,n = map(int,input().split())
p = []
inf = 10**9
for i in range(n):
    a,b = map(int,input().split())
    p.append([a,b])
m = [[0 for i in range(h)]for i in range(n+1)]
for i in range(n+1):
    for j in range(h):
        m[i][j] = inf
for i in range(n):
    for j in range(h):
        if p[i][0] >= j+1:
            m[i+1][j] = min(m[i][j],p[i][1])
        else:
            m[i+1][j] = min(m[i][j],m[i+1][j-p[i][0]]+p[i][1])
print(m[n][h-1])

### FIXED CODE ###

h,n = map(int,input().split())
p = []
inf = 10**9
for i in range(n):
    a,b = map(int,input().split())
    p.append([a,b])
m = [[0 for i in range(h)]for i in range(n+1)]
for i in range(n+1):
    for j in range(h):
        m[i][j] = inf
for i in range(n):
    for j in range(h):
        if p[i][0] >= j+1:
            m[i+1][j] = min(m[i][j],p[i][1])
        else:
            m[i+1][j] = min(m[i][j],m[i+1][j-p[i][0]]+p[i][1])
print(m[n][h-1])
### BUGGY CODE ###

import bisect
n=int(input())
l=sorted(list(map(int,input().split())))

cnt=0
for i in range(0,n-1):
    for j in range(i+1,n):
        k=bisect.bisect_left(l,l[j]+1)
        p=bisect.bisect_right(l,l[i]+l[j]-1)
        cnt+=p-k
print(cnt)


### FIXED CODE ###

import bisect
n=int(input())
l=sorted(list(map(int,input().split())))

cnt=0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        p=bisect.bisect_right(l,l[i]+l[j]-1)
        cnt+=max(p-j-1,0)
print(cnt)
### BUGGY CODE ###

k, s = map(int, input().split())

cnt = 0
for l in range(k+1):
  for m in range(k+1):
    for n in range(k+1):
      if (l + m + n == s):
        cnt += 1
print(cnt)

### FIXED CODE ###

k, s = map(int, input().split())

cnt = 0
for l in range(k+1):
  for m in range(k+1):
    n = s - l - m
    if 0 <= n <= k:
      cnt += 1
print(cnt)
### BUGGY CODE ###

import math
from functools import reduce

def gcd_(*num):
    return reduce(math.gcd, num)


k = int(input())
ans = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        for m in range(1, k+1):
#             l = list(i, j, m)
            res =gcd_(i, j, m)
            ans += res
print(ans)

### FIXED CODE ###

from math import gcd

k = int(input())
res = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        for m in range(1, k+1):
            res += gcd(gcd(i, j), m)

print(res)
### BUGGY CODE ###

def sieve(N):#エラトステネスの篩
    prime = [0]*(N+1)
    isprime = [True]*(N+1)
    isprime[0]=isprime[1] = False
    num = 0
    for p in range(2,N+1):
        if isprime[p]:
            prime[num] = p
            num += 1
            for j in range(2*p,N+1,p):
                isprime[j] = False
    return prime
from bisect import bisect_left as bl
lis = sieve(10**5)
prime = set(lis)-{0}
for i in range(len(lis)):
    if lis[i] != 0:
        if (lis[i]+1)//2 in prime:continue
        else:lis[i] = 0
    else:continue
Q = int(input())
lis = set(lis)-{0}
lis = sorted(tuple(lis))
for _ in range(Q):
    l,r = map(int,input().split())
    t = bl(lis,l)
    tmp = 0
    if t == len(lis):print(tmp);continue
    while t < len(lis) and lis[t] <= r:
        tmp += 1
        t += 1
    print(tmp)



### FIXED CODE ###

def sieve(N):#エラトステネスの篩
    prime = [0]*(N+1)
    isprime = [True]*(N+1)
    isprime[0]=isprime[1] = False
    num = 0
    for p in range(2,N+1):
        if isprime[p]:
            prime[num] = p
            num += 1
            for j in range(2*p,N+1,p):
                isprime[j] = False
    return prime
from bisect import bisect_left as bl
from bisect import bisect_right as br
lis = sieve(10**5)
prime = set(lis)-{0}
for i in range(len(lis)):
    if lis[i] != 0:
        if (lis[i]+1)//2 in prime:continue
        else:lis[i] = 0
    else:continue
Q = int(input())
lis = set(lis)-{0}
lis = sorted(tuple(lis))
for _ in range(Q):
    l,r = map(int,input().split())
    t = bl(lis,l)
    s = br(lis,r)
    tmp = s-t
    print(tmp)
### BUGGY CODE ###

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

c = 0

for i in a_lst:
    if i == 0:
        print(0)
        c = 1
        break
if c != 1:
    for i, alst in enumerate(a_lst):
        if i == 0:
            b = alst
        else:
            b = b * alst
    
    if b > 1000000000000000000:
        print('-1')
    else:
        print(b)

### FIXED CODE ###

N = int(input())
A= list(map(int, input().split()))
result=1
if 0 in A:
    result = 0
else:
    for t in range(N):
        result *= A[t]
        if result > 10 ** 18:
            result = -1
            break
print(result)
### BUGGY CODE ###


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

buka = [str(A.count(i)) for i in range(1, N+1, 1)]

print("\n".join(buka))

### FIXED CODE ###


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

buka = [str(A.count(i)) for i in range(1, N+1, 1)] # countメソッドのためTLE

print("\n".join(buka))
"""
"""
# sys（入力メイン）-----------------------------------------
import sys
read = sys.stdin.buffer.read # 全読み込み
readline = sys.stdin.buffer.readline # 一行読み込み
readlines = sys.stdin.bufer.readlines # 一行ずつ全読み込み
sys.setrecursionlimit(10**7) # 再帰限界変更（デフォルトは1000）

# 文字列（数値変換も含む）
n = readline().rstrip() # １行に１文字列のみ
lis = readline().rstrip().split() # # １行に複数の文字列

# 数値（文字変換も含む）
n = int(readline().rstrip()) # １行に数値１個のみ
a, b, c = int(readline().rstrip().split()) # １行に複数の数値
lis = [readline().rstrip().split() for _ in range(n)] # １行に複数の数値(m個)かつ、n行続く場合（出力は二次元リスト：[['1', '2'], ['4', '5']]）

-----------------------------------------
"""

import sys
read = sys.stdin.buffer.read # 全読み込み
readline = sys.stdin.buffer.readline # 一行読み込み
readlines = sys.stdin.buffer.readlines # 一行ずつ全読み込み
sys.setrecursionlimit(10**7) # 再帰限界変更（デフォルトは1000）

N = int(readline().rstrip()) 
A = list(map(int,readline().rstrip().split()))

buka=[0]*N

for i in range(N-1):
    buka[A[i]-1]+=1

L=[str(a) for a in buka]
L="\n".join(L)
print(L)
### BUGGY CODE ###

import queue
WHITE = 0
GRAY = 1
BLACK = 2
INFTY = 10**16
def dijkstra(s, V):
    color = [WHITE for i in range(N+1)]
    d = [INFTY for i in range(N+1)]
    d[s] = 0
    q = queue.Queue()
    q.put(s)

    while not q.empty():
        u = q.get()
        color[u] = BLACK

        for v in V[u]:
            if color[v] != BLACK and d[v] == INFTY:
                d[v] = d[u] + 1
                q.put(v)

    return d
def rec(s, i, depth):
    if depth == 3:
        kkpgraph[s].append(i)
        return
    if not graph[i]:
        return
    for node in graph[i]:
        rec(s, node, depth+1)
    return

N, M = map(int, input().split())
graph = [[] for i in range(N+1)]
kkpgraph = [[] for i in range(N+1)]
for i in range(M):
    u, v = map(int, input().split())
    graph[u].append(v)
S, T = map(int, input().split())
for i in range(1, N+1):
    rec(i, i, 0)
d = dijkstra(S, kkpgraph)
if d[T] == INFTY:
    print(-1)
else:
    print(d[T])


### FIXED CODE ###

import queue
WHITE = 0
GRAY = 1
BLACK = 2
INFTY = 10**16
def bfs(s, V):
    color = [[WHITE for i in range(N+1)] for j in range(3)]
    d = [[INFTY for i in range(N+1)] for j in range(3)]
    d[0][s] = 0
    q = queue.Queue()
    q.put((0, s))
    
    while not q.empty():
        dv, u = q.get()
        color[dv%3][u] = BLACK

        for v in V[u]:
            if color[(dv+1)%3][v] != BLACK and d[(dv+1)%3][v] == INFTY:
                d[(dv+1)%3][v] = d[dv%3][u] + 1
                q.put((d[(dv+1)%3][v], v))

    return d

N, M = map(int, input().split())
graph = [[] for i in range(N+1)]
for i in range(M):
    u, v = map(int, input().split())
    graph[u].append(v)
S, T = map(int, input().split())
d = bfs(S, graph)
if d[0][T] == INFTY:
    print(-1)
else:
    print(d[0][T]//3)
### BUGGY CODE ###

n = input()
l = [int(each) for each in input().split()]
result = 1
for each in l:
    result *= each
if result > 10**18:
    result = -1
print(result)

### FIXED CODE ###

n = input()
l = [int(each) for each in input().split()]
if 0 in l:
    print(0)
else:
    result = 1
    for each in l:
        result *= each
        if result > 1000000000000000000:
            result = -1
            break
    print(result)
### BUGGY CODE ###

n = int(input())
num = input().split()

for i in range(1,n+1):
    print(num.count(str(i)))


### FIXED CODE ###

n = int(input())
num = [0] * n
employee = list(map(int,input().split()))

for i in employee:
    num[i-1] += 1

for j in num:
    print(j)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
A.sort()
cnt = 0
dp = [True]*(A[-1]+1)

for i in range(N-1):
  if dp[A[i]] == True:
    for j in range(A[i], max(A)+1,A[i]):
      dp[j] = False
    if A[i] != A[i+1]:
      cnt+=1
if dp[A[-1]] == True:
  cnt+=1
print(cnt)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
A.sort()
cnt = 0
dp = [True]*(A[-1]+1)

for i in range(N-1):
  if dp[A[i]] == True:
    for j in range(A[i], A[-1]+1,A[i]):
      dp[j] = False
    if A[i] != A[i+1]:
      cnt+=1
if dp[A[-1]] == True:
  cnt+=1
print(cnt)
### BUGGY CODE ###

N,M=map(int,input().split())
S=[]
for i in range(N):
    A,B=map(int,input().split())
    S.append([A,B])

S.sort()
m=0

for i in range(M):
    for j in range(N):
        if S[j][1]!=0:
            m+=S[j][0]
            S[j][1]-=1
            break

print(m)



    

### FIXED CODE ###

N,M=map(int,input().split())
S=[]
for i in range(N):
    A,B=map(int,input().split())
    S.append([A,B])

S.sort()
m=0
while M>0:
    for i in range(N):
        if S[i][1]<=M:
            m+=S[i][0]*S[i][1]
            M-=S[i][1]
        else:
            m+=S[i][0]*M
            M=0
            break

print(m)
### BUGGY CODE ###

N=int(input())
X=input()
popcount=X.count('1')
Xnum1 = 0
Xnum0 = 0
if popcount != 1:
    for i in range(N):
        Xnum1 = (Xnum1 + int(X[i])*(2**(N-i-1)%(popcount-1)))%(popcount-1)
for i in range(N):
    Xnum0 = (Xnum0 + int(X[i])*(2**(N-i-1)%(popcount+1)))%(popcount+1)
for i in range(N):
    if popcount==1 and X[i]=='1':
        print(0)
        continue
    if X[i]=='1':
        Xi = (Xnum1 - (2**(N-i-1)%(popcount-1)))%(popcount-1)
    else:
        Xi = (Xnum0 + (2**(N-i-1)%(popcount+1)))%(popcount+1)
    ans = 1
    while Xi!=0:
        Xi = Xi % bin(Xi).count('1')
        ans += 1
    print(ans)

### FIXED CODE ###

N=int(input())
X=input()
popcount=X.count('1')
bi1=[]
bi0=[]
Xnum1 = 0
Xnum0 = 0
if popcount != 1:
    for i in range(N):
        if i==0: bi1.append(1)
        else: bi1.append(bi1[i-1]*2%(popcount-1))
        Xnum1 = (Xnum1 + int(X[N-i-1])*bi1[i])%(popcount-1)
for i in range(N):
    if i==0: bi0.append(1)
    else: bi0.append(bi0[i-1]*2%(popcount+1))
    Xnum0 = (Xnum0 + int(X[N-i-1])*bi0[i])%(popcount+1)
for i in range(N):
    if popcount==1 and X[i]=='1':
        print(0)
        continue
    if X[i]=='1':
        Xi = (Xnum1 - bi1[N-i-1])%(popcount-1)
    else:
        Xi = (Xnum0 + bi0[N-i-1])%(popcount+1)
    ans = 1
    while Xi!=0:
        Xi = Xi % bin(Xi).count('1')
        ans += 1
    print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())

bridge1 = []
bridge2 = []
for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        bridge1.append((a, b))
    if b == N:
        bridge2.append((a, b))

for b1 in bridge1:
    for b2 in bridge2:
        if b1[1] == b2[0]:
            print('POSSIBLE')
            exit()
print('IMPOSSIBLE')

### FIXED CODE ###

N, M = map(int, input().split())

bridge1 = []
bridge1_right = set()
bridge2 = []
bridge2_left = set()
for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        bridge1.append((a, b))
        bridge1_right.add(b)
    if b == N:
        bridge2.append((a, b))
        bridge2_left.add(a)

if len(bridge1) == 0 or len(bridge2) == 0:
    print('IMPOSSIBLE')
    exit()

if len(bridge1_right & bridge2_left) > 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
### BUGGY CODE ###

import itertools
import math
import numpy as np
import sys
input = sys.stdin.readline

n = int(input())
xy = np.array([list(map(int, input().split())) for _ in range(n)])

n_list = [l for l in range(n)]
dsum = 0
for i in itertools.permutations(n_list, n):
    skip = 1
    for j in i:
        if skip:
            skip = 0
            xy1 = xy[j]
        else:
            xy2 = xy[j]
            dsum += np.sqrt(np.sum((xy1 - xy2)**2))
            xy1 = xy2

print(dsum/math.factorial(n))


### FIXED CODE ###

import itertools
import math
import numpy as np
import sys
input = sys.stdin.readline

n = int(input())
xy = np.array([list(map(int, input().split())) for _ in range(n)])

n_list = [l for l in range(n)]
dsum = 0
for i in itertools.permutations(n_list, n):
    xy1 = xy[list(i)][:-1]
    xy2 = xy[list(i)][1:]
    dsum += np.sum(np.sqrt(np.sum((xy1 - xy2)**2, axis=1)))

print(dsum/math.factorial(n))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(pow(10, 8))
N = int(input())
As = list(map(int, input().split()))
d = dict()
def decode(x):
    return [(x // ((N+1)**i))%(N+1) for  i in range(4)]
def f(x):
    if x in d:
        return d[x]
    E = 0
    _x = decode(x)
    for i in range(1, 4):
        if _x[i]:
            E += (_x[i]*N)/((N-_x[0])**2) + f(x - (N+1)**i + (N+1)**(i-1))*(_x[i]/(N-_x[0]))
    d[x] = E
    return E
B = 0
for a in As:
    B += (N+1)**a
print(f(B))


### FIXED CODE ###

N = int(input())
As = list(map(int, input().split()))
d = dict()
def encode(i,j,k):
    return i+j*(N+1)+k*((N+1)**2)
def decode(x):
    return [(x // ((N+1)**i))%(N+1) for  i in range(3)]
B = 0
for a in As:
    B += (N+1)**(a-1)
d[0] = 0
for k in range(N+1):
    for j in range(N+1-k):
        for i in range(N+1-k-j):
            E = 0
            x = encode(i,j,k)
            s0 = N-i-j-k
            if i:
                E += (i*N)/((N-s0)**2) + d[x-1]*(i/(N-s0))
            if j:
                E += (j*N)/((N-s0)**2) + d[x-N]*(j/(N-s0))
            if k:
                E += (k*N)/((N-s0)**2) + d[x-N**2-N]*(k/(N-s0))
            d[x] = E
print(d[B])
### BUGGY CODE ###

n=int(input())
a=[int(x) for x in input().split()]
b=1
for i in range(n):
  b*=a[i]
if b>10**18:
  print(-1)
else:
  print(b)

### FIXED CODE ###

n=int(input())
a=[int(x) for x in input().split()]
if 0 in a:
  print(0)
else:
  b=1
  for i in range(n):
    b*=a[i]
    if b>10**18:
      print(-1)
      exit()
  print(b)
### BUGGY CODE ###

while True:
    n = input()
    if n == 0: break
    ans = [0,0,0,0,0,0,0]
    for i in xrange(n):
        age = input()
        if age <= 9:
            ans[0] += 1
        elif age <= 19:
            ans[1] += 1
        elif age <= 29:
            ans[2] += 1
        elif age <= 39:
            ans[3] += 1
        elif age <= 49:
            ans[4] += 1
        elif age <= 59:
            ans[5] += 1
        else:
            ans[6] += 1
    for c in ans:
        print c

### FIXED CODE ###

while True:
    n = int(raw_input())
    if n == 0: break
    ans = [0 for i in range(7)]
    for i in xrange(n):
        age = int(raw_input())
        if age <= 9:
            ans[0] += 1
        elif age <= 19:
            ans[1] += 1
        elif age <= 29:
            ans[2] += 1
        elif age <= 39:
            ans[3] += 1
        elif age <= 49:
            ans[4] += 1
        elif age <= 59:
            ans[5] += 1
        else:
            ans[6] += 1
    for c in ans:
        print c