import java.io.*;
import java.lang.*;
import java.util.*;
public class Main{
    public static long sumGCD(long[] arr){
        long max=0;
        for(int i=0;i<arr.length;i++)
            if(arr[i]>max) max=arr[i];
        long[] c=new long[(int)max+1];
        long[] d=new long[(int)max+1];
        long[] e=new long[(int)max+1];
        for(int i=0;i<arr.length;i++) c[(int)arr[i]]++;
        for(int i=1;i<=max;i++){
            for(int j=i;j<=max;j+=i) d[i]+=c[j];
        }
        for(int i=(int)max;i>=1;i--){
            e[i] = d[i]*d[i]*d[i];
            for(int j=2*i;j<=max;j+=i) e[i] -= e[j];
        }
        long sum=0;
        for(int i=1;i<=max;i++) sum+=(i*e[i]);
        return sum;
    }
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        long[] arr=new long[n];
        for(int i=1;i<=n;i++) arr[i-1]=i;
        long ans=sumGCD(arr);
        System.out.println(ans);
    }
}


import java.io.*;
import java.util.*;

class Main {
	public static void main(String[] args) throws IOException {
		Scan sc = new Scan();
		int K = sc.scanInt();
		SolABC162_c sol = new SolABC162_c(K);
		sol.calcMu();
		sol.calcGCDTuple(3);
	}
}

class SolABC162_c {
	int K;
	int[] mu, prime;

	public SolABC162_c(int K) {
		this.K = K;
		mu = new int[K + 1];
		prime = new int[K + 1];
		for (int i = 1; i <= K; ++i) {
			mu[i] = 1;
			prime[i] = 1;
		}
	}

	void calcMu() {
		for (int i = 2; i <= K; ++i) {
			if (prime[i] == 1) {
				for (int j = i; j <= K; j += i) {
					if (j > i)
						prime[j] = 0;
					if (j % (i * i) == 0)
						mu[j] = 0;
					mu[j] = -mu[j];
				}
			}
		}
	}

	void calcGCDTuple(int cnt) {
		long res = 0;
		for (int d = 1; d <= K; ++d) {
			long tmp = 0;
			for (int s = 1; s <= K / d; ++s) {
				tmp += (mu[s] * Math.pow(K / (d * s), cnt));
			}
			res += tmp * d;
		}
		System.out.println(res);
	}
}

class Scan {
    private byte[] buf=new byte[1024];
    private int index;
    private InputStream in;
    private int total;

    public Scan()
    {
        in=System.in;
    }
    public int scan()throws IOException
    {
        if(total<0)
        throw new InputMismatchException();
        if(index>=total)
        {
            index=0;
            total=in.read(buf);
            if(total<=0)
            return -1;
        }
        return buf[index++];
    }
    public int scanInt()throws IOException
    {
        int integer=0;
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        int neg=1;
        if(n=='-')
        {
            neg=-1;
            n=scan();
        }
        while(!isWhiteSpace(n))
        {
            if(n>='0'&&n<='9')
            {
                integer*=10;
                integer+=n-'0';
                n=scan();

            }
            else throw new InputMismatchException();
        }
        return neg*integer;
    }
	public long scanLong()throws IOException
    {
        long integer=0;
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        int neg=1;
        if(n=='-')
        {
            neg=-1;
            n=scan();
        }
        while(!isWhiteSpace(n))
        {
            if(n>='0'&&n<='9')
            {
                integer*=10;
                integer+=n-'0';
                n=scan();
            }
            else throw new InputMismatchException();
        }
        return neg*integer;
    }
    public double scanDouble()throws IOException
    {
        double doub=0;
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        int neg=1;
        if(n=='-')
        {
            neg=-1;
            n=scan();
        }
        while(!isWhiteSpace(n)&&n!='.')
        {
            if(n>='0'&&n<='9')
            {
                doub*=10;
                doub+=n-'0';
                n=scan();
            }
            else throw new InputMismatchException();
        }
        if(n=='.')
        {
            n=scan();
            double temp=1;
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    temp/=10;
                    doub+=(n-'0')*temp;
                    n=scan();
                }
                else throw new InputMismatchException();
            }
        }
        return doub*neg;
    }
    public String scanString()throws IOException
    {
        StringBuilder sb=new StringBuilder();
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        while(!isWhiteSpace(n))
        {
            sb.append((char)n);
            n=scan();
        }
        return sb.toString();
    }
    private boolean isWhiteSpace(int n)
    {
        if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
        return true;
        return false;
    }
}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();

		int total = 0;

		for(int a = 1; a < k+1; a++) {
			for(int b = 1; b < k+1; b++) {
				for(int c = 1; c < k+1; c++) {
					total += gcd(gcd(a, b), c);
				}
			}
		}
		System.out.println(total);
	}

	//ユークリッドの互除法
	static int gcd(int p, int q) {
		if(p % q == 0)	return q;	//最大公約数
		return gcd(p, p % q);		//答えが見つかるまで繰り返し
	}

}


import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = 1, b = 1, c = 1;
        int r = 0;
        int s = 0;
        int value = 0;

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                a = i; b = j;
                while( (r = a % b) != 0 ) {
                    a = b;
                    b = r;
                }
                for (int k = 1; k <= n; k++) {
                    c = k;
                    while( (r = b % c) != 0 ) {
                        b = c;
                        c = r;
                    }
                    value += c;
                }
            }
        }

        System.out.println(value);
    }
}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int K = scan.nextInt();
		int sum = 0;

		for (int i = 1; i <= K; i++) {
			for (int j = 1; j <= K; j++) {
				for (int k = 1; k <= K; k++) {
					sum += gcd(i, gcd(j , k));
				}
			}
		}

	}

	static int gcd(int p, int q) {
		if (p % q == 0) {
			return q;
		}
		return gcd(q, p % q);
	}
}


#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

int n=3,k;

int main(){
	cin>>k;
	vl dp(k+1);
	for(int i=k;i>0;i--){
		dp[i]=Pow(k/i,n);
		for(int j=2*i;j<=k;j+=i) dp[i]=(dp[i]-dp[j]+mod)%mod;
	}
	ll res=0;
	for(int i=1;i<=k;i++) (res+=dp[i]*i)%=mod;
	cout<<res<<endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

ll get(ll x, ll y) {
  ll res = 1ll;
  while(y) {
    if(y & 1) {
      res = (res * x) % MOD;
    }
    y >>= 1;
    x = (x * x) % MOD;
  }
  return res;
}

void solve() {
  int n, k; n = 3; cin >> k;
  vector <ll> cur(k + 1);
  for(int i = 1; i <= k; i++) {
    cur[i] = get((k / i), n);
  }
  for(int i = k; i >= 1; i--) {
    for(int j = i + i; j <= k; j += i) {
      cur[i] -= cur[j];
      cur[i] %= MOD;
      if(cur[i] < 0) cur[i] += MOD;
    }
  }
  ll ans = 0;
  for(ll i = 1; i <= k; i++) {
    //cout << cur[i] << '\n';
    ans = (ans + i * cur[i]) % MOD;
  }
  cout << ans << '\n';
}

int main() {
  int t; t = 1;
  for(int cs = 1; cs <= t; cs++) {
    solve();
  }
}


#include <bits/stdc++.h>
using namespace std;

int64_t beki(int64_t n,int64_t x){
 int64_t s,ans;
  s=(n*n)%1000000007;
  ans=(s*n)%1000000007;
  return ans;}

int main() {
int64_t n,k,a;
  a=0;
  n=3;
  cin>>k;
  vector<int64_t> ans(k);
  ans.at(k-1)=1;
  for(int64_t i=k-2;i>=0;i--){
  ans.at(i)=beki(k/(i+1),3);
    for(int64_t j=1;(i+1)*j<=k;j++){
    ans.at(i)=ans.at(i)-ans.at((i+1)*j-1);
     }
    ans.at(i)=ans.at(i)+beki(k/(i+1),3);
  }
  for(int64_t i=0;i<k;i++){a=a+(i+1)*ans.at(i);
  while(a>=1000000007){a=a-1000000007;}}
  cout<<a<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
//#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it<<" ";}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se.fi<<" "<<it.se.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 1000000007
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double
#define re(s) reverse(s.begin(),s.end())
#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
int powe(int x,int n)
{
  if(n==0)return 1;
  if(n%2==0)
    return powe((x%mod*x%mod)%mod,n/2)%mod;
  return (x%mod*powe((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
int gcd(int A,int B)
{
  if(B==0)return A;
  return gcd(B,A%B);
}

int32_t main()
{
  io
int k;
cin>>k;int ans=0;
for(int i=1;i<=k;i++)
{
  for(int j=1;j<=k;j++)
  {
    for(int kk=1;kk<=k;kk++)
    {
      ans+=__gcd(i,__gcd(j,k));
    }
  }
}
cout<<ans<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
//#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it<<" ";}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se.fi<<" "<<it.se.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 1000000007
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double
#define re(s) reverse(s.begin(),s.end())
#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
int powe(int x,int n)
{
  if(n==0)return 1;
  if(n%2==0)
    return powe((x%mod*x%mod)%mod,n/2)%mod;
  return (x%mod*powe((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
int gcd(int A,int B)
{
  if(B==0)return A;
  return gcd(B,A%B);
}

int32_t main()
{
  io
int k;
cin>>k;
for(int i=1;i<=k;i++)
{
  for(int j=1;j<=k;j++)
  {
    for(int kk=1;kk<=k;kk++)
    {
      ans+=__gcd(i,__gcd(j,k));
    }
  }
}
cout<<ans<<endl;

}


#include<iostream>
#include<stdio.h>
using namespace std;
using ll=long long;
#include<algorithm>
#include<set>
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using P=pair<int,int>;
#include<cmath>

int main(){
  int k;
  cin>>k;
  int ans=0;
rep(i,k)rep(j,k)rep(n,k){
  ans+=gcd(i,gcd(j,n));
}
cout<<ans<<endl;
return 0;
}


#include <stdio.h>
typedef long long int lld;

int main(void) {
  int k;
  lld cnt[200], s = 0;
  scanf("%d", &k);
  for (int i = k; i > 0; i--) {
    cnt[i - 1] = (k / i);
    cnt[i - 1] *= cnt[i - 1] * cnt[i - 1];
    for (int j = i * 2; j <= k; j += i) {
      cnt[i - 1] -= cnt[j - 1];
    }
    s += i * cnt[i - 1];
  }
  printf("%lld\n", s);
}


#include<stdio.h>
int gdc(int i, int j, int k) {

	int c = 0;
	int tmp = 0;

	/*iが大きくなるように並び替える*/
	if (i < j) {

		tmp = i;
		i = j;
		j = tmp;
	}

	c = i % j;
	/*iとjの最大公約数を求める*/

	while (c > 0) {

		i = j;

		j = c;
		c = i % j;

	}

	/*i,jの最大公約数jと,kから、これらの最大公約数を求める*/

	/*kの方が大きければ入れ替える*/
	if (j < k) {

		tmp = j;
		j = k;
		k = tmp;

	}

	int d = j % k;

	while (d > 0) {

		j=k;
		k = d;
		d= j%k;

	}

	return k;
}

int main(void) {

	int i = 0;
	int j = 0;
	int k = 0;
	int n = 0;

	int c = 0;
	int sum = 0;

	scanf("%d", &n);

	for (i = 1; i <= n; i++) {

		for (j = 1; j <= n; j++) {

			for (k = 1; k <= n; k++) {

				c = gdc(i, j, k);

				printf("%d\n", c);
				sum = sum + c;

			}

		}

	}

	printf("答えは%d", sum);
	return 0;

}


#include<stdio.h>
int main() {
    int n, m, vote = 0, count = 0, a[100];
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; i++)
    {
        total = total + a[i];
    }
    for (int i = 0; i < n; i++)
    {
        if (a[i] >= total / (4 * m))
        {
            count = count + 1;
        }

    }

    if (count >= m)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n")
    }

    return 0;
}


#include <stdio.h>
int main(){
  int gcd(int p, int q) {
    while (q != 0) {
      int r = p % q;
      p = q;
      q = r;
    }
    return p;
  }

int main(){
    int k;
    scanf("%d", &k);
    long sum = 0;

    for (int a = 1; a <= k; a++)
      for (int b = 1; b <= k; b++)
        for (int c = 1; c <= k; c++)
          sum += gcd(gcd(a, b), c);

    printf("%ld", sum);
    return 0;
 }


"use strict";

const gcd = (a, b) => {
    if (b > a)
        return gcd(b, a);
    if (b === 0)
        return a;
    return gcd(b, (a % b));
}

const main = (input) => {
    const spi = input.split('\n');
    const k = Number(spi[0]);

    let ans = 0;
    for (let a = 1; a <= k; a++) {
        for (let b = 1; b <= k; b++) {
            let x = gcd(a, b);
            for (let c = 1; c <= k; c++) {
                ans += gcd(x, c);
            }
        }
    }

    console.log(ans);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


function gcd2(a, b) {
  let m, n
  if (a >= b) {
    m = a
    n = b
  } else {
    m = b
    n = a
  }
  let bn = n
  n = m % n
  m = bn
  while(n !== 0) {
    bn = n
    n = m % n
    m = bn
  }
  return m
}
function gcd(a, b, c) {
  return gcd2(gcd2(a, b), c)
}

function main(input) {
  const K = Number(input)
  let sum = 0
  for(let i = 1; i <= K; i++) {
    for(let j = 1; j <= K; j++) {
      for(let k = 1; k <= K; k++) {
        // console.log(i, j, k, gcd(i, j, k))
        sum += gcd(i, j, k)
      }
    }
  }
  console.log(sum)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


const gcd = (m, n) => {
  while (n > 0) {
    const r = m % n
    m = n
    n = r
  }
  return m
}

const Main = (input) => {
  const tmp = parseInt(input.trim())

  let result = 0

  for (let i = 1; i <= tmp; ++i) {
    for (let j = 1; j <= tmp; ++j) {
      for (let k = 1; k <= tmp; ++k) {
        result += gcd(gcd(i, j), k)
      }
    }
  }

  console.log(result)
  return result
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))


"use strict";
let m = {}
const helper = function (a, b, c) {
    let arr = [a,b,c]
    arr.sort()
    const key = arr.join("")
    if(m[key]) return m[key]
    const max = Math.max(a, b, c)
    for (let i = max; i >= 1; i--) {
        if (a % i == 0 && b % i == 0 && c % i == 0){
            m[key] = i
            return i
        }
    }
    return 1
}

const main = arg => {
    const input = arg.trim().split("\n");
    const K = parseInt(input[0]);
    let res = 0
    for (let a = 1; a <= K; a++) {
        for (let b = 1; b <= K; b++) {
            for (let c = 1; c <= K; c++) {
                res = res + helper(a, b, c)
            }
        }
    }
    console.log(res)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


"use strict";

const helper = function (a, b, c) {
    const max = Math.max(a, b, c)
    for (let i = max; i >= 1; i--) {
        if (a % i == 0 && b % i == 0 && c % i == 0) return i
    }
    return 1
}

const main = arg => {
    const input = arg.trim().split("\n");
    const K = parseInt(input[0]);
    let res = 0
    for (let a = 1; a <= K; a++) {
        for (let b = 1; b <= K; b++) {
            for (let c = 1; c <= K; c++) {
                res = res + helper(a, b, c)
            }
        }
    }
    console.log(res)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
  var input = require('fs').readFileSync('/dev/stdin', 'utf8');
  var result = 0;
  for (var a = 1; a <= input; a++) {
    for (var b = 1; b <= input; b++) {
      for (var c = 1; c <= input; c++) {
        // console.log(a + " " + b + " " + c);
        result += gcd(gcd(a, b), c);
      }
    }
  }
  console.log(result);
}

function gcd(a, b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a%b);
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	for a%b != 0 {
		a, b = b, a%b
	}
	return b
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	K := nextInt()

	g := make([][]int, K+1)
	for i := range g {
		g[i] = make([]int, K+1)
		for j := range g[i] {
			g[i][j] = gcd(i, j)
		}
	}

	ans := 0
	for i := 1; i <= K; i++ {
		for j := 1; j <= K; j++ {
			for k := 1; k <= K; k++ {
				ans += g[g[i][j]][k]
			}
		}
	}
	puts(ans)
}


package main

import "fmt"

func main() {
	var K, sum int
	fmt.Scan(&K)
	w := make([][]int, K+1)
	for i := 0; i < len(w); i++ {
		w[i] = make([]int, K+1)
		for j := 0; j < len(w[i]); j++ {
			w[i][j] = gcd(i, j)
		}
	}
	for a := 1; a <= K; a++ {
		for b := 1; b <= K; b++ {
			for c := 1; c <= K; c++ {
				sum += w[w[a][b]][c]
			}
		}
	}
	fmt.Println(sum)
}
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}


package main

import (
	"fmt"
)

var N, ANS int
func main() {
	fmt.Scan(&N)
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			for k := 0; k < N; k++ {
				ANS += gcd(i + 1, j + 1, k + 1)
			}
		}
	}
	fmt.Println(ANS)
}

func gcd(a, b, c int)  int {
  ans := 1
  for i := 1; i <= N; i++ {
	  if a % i == 0 && b % i == 0 && c % i == 0 {
		  ans = i
	  }
  }
  return ans
}


package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

func gcd(m, n uint64) uint64 {
	x := new(big.Int)
	y := new(big.Int)
	z := new(big.Int)
	a := new(big.Int).SetUint64(m)
	b := new(big.Int).SetUint64(n)
	return z.GCD(x, y, a, b).Uint64()
}

func threeGcd(a, b, c int) int {
	array := []int{a, b, c}
	sort.Ints(array)
	gcsMin := gcd(uint64(array[0]), uint64(array[1]))
	return int(gcd(gcsMin, uint64(array[2])))
}

var sum int

func dfs(a, b, c int) {
	for x := c; 0 < x; x-- {
		for y := c; 0 < y; y-- {
			for z := c; 0 < z; z-- {
				sum += threeGcd(x, y, z)
			}
		}
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	k := nextInt()
	dfs(k, k, k)
	fmt.Println(sum)
}


package main

import (
  "fmt"
  "sort"
)

func main(){
  var N, ans int
  fmt.Scan(&N)

  for i := 1; i<=N; i++ {
    for j := 1; j<=N; j++ {
      for k := 1; k<=N; k++ {
        ans += gcd(i,j,k)
      }
    }
  }
  fmt.Println(ans)
}

func gcd(a,b,c int) int {
  var R int
  val :=[]int{a, b, c}
  sort.Ints(val)

  A := val[0]
  B := val[1]
  C := val[2]

  for {
    R = abs(A - B)
    if R == 0 {
      R = A
      break
    }
    A = B
    B = R
  }
  if B < C {
    Ctmp := C
    C = B
    B = Ctmp
  }
  for {
    R = abs(B-C)
    if R == 0 {
      R = B
      break
    }
    B = C
    C = R
  }
  return R
}

func abs(a int) int {
  if a < 0 {
    return -a
  }
  return a
}


mod = 10 ** 9 + 7

k,*_ = gets.split.map(&:to_i)
n = 3

a = [1] * (k+1)
b = Array.new(k+1){|i| i }

(k/2).downto(1) do |i|
  cnt = ( k/i ).pow( n, mod )
  (i*2).step(k, i){|j| cnt = ( cnt - a[j] ) % mod }
  a[i] = cnt
  b[i] = i * cnt % mod
end

ans = 0
(1..k).each do |i|
  ans += b[i]
  ans %= mod if ans >= mod
end

puts ans


puts [0, 1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692][gets.to_s.to_i]


arr = [0, 1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692]
p arr[gets.to_i]


k = gets.to_i
ans = 0
def gcd(i,j,k)
    x = i
    y = j
    z = k
    while y != 0
        x,y = y,x%y
    end
    while z != 0
        x,z = z,x%z
    end
    return x
end
k.times do |a|
    k.times do |b|
        k.times do |c|
            ans += gcd(a+1,b+1,c+1)
        end
    end
end
puts ans


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

def gcd_3elem(a, b, c)
  gcd_2elem = gcd(a, b)
  gcd(c, gcd_2elem)
end

n = gets.chomp.to_i

s = 0
(1..n).each do |i|
  (1..n).each do |j|
    (1..n).each do |k|
      s += gcd_3elem(i, j, k)
    end
  end
end

puts s


# array = [*1..q].map { |_| gets.split.map(&:to_i) }
# n = gets.split.map(&:to_i)
# a = [*1..m].repeated_combination(n).to_a

k = gets.to_i

a = [*1..k].repeated_permutation(3).to_a

s = 0
a.each do |ary|
  s += ary[0].gcd(ary[1]).gcd(ary[2])
end

puts s


use std::io::stdin;fn main(){let result:Vec<u32> = [1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692].to_vec();let mut st = String::new();stdin().read_line(&mut st).unwrap();let k = st.trim().parse::<usize>().unwrap();println!("{:?}",result[k-1]);}


use std::io::stdin;

fn main() {
    let result:Vec<i32> = [1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692].to_vec();
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let k = st.trim().parse::<usize>().unwrap();
    println!("{:?}",result[k-1]);
}


// ---------- begin ModInt ----------
const MOD: u32 = 1_000_000_007;

#[derive(Clone, Copy)]
struct ModInt(u32);

impl std::ops::Add for ModInt {
    type Output = ModInt;
    fn add(self, rhs: ModInt) -> Self::Output {
        let mut d = self.0 + rhs.0;
        if d >= MOD {
            d -= MOD;
        }
        ModInt(d)
    }
}

impl std::ops::AddAssign for ModInt {
    fn add_assign(&mut self, rhs: ModInt) {
        *self = *self + rhs;
    }
}

impl std::ops::Sub for ModInt {
    type Output = ModInt;
    fn sub(self, rhs: ModInt) -> Self::Output {
        let mut d = self.0 + MOD - rhs.0;
        if d >= MOD {
            d -= MOD;
        }
        ModInt(d)
    }
}

impl std::ops::SubAssign for ModInt {
    fn sub_assign(&mut self, rhs: ModInt) {
        *self = *self - rhs;
    }
}

impl std::ops::Mul for ModInt {
    type Output = ModInt;
    fn mul(self, rhs: ModInt) -> Self::Output {
        ModInt((self.0 as u64 * rhs.0 as u64 % MOD as u64) as u32)
    }
}

impl std::ops::MulAssign for ModInt {
    fn mul_assign(&mut self, rhs: ModInt) {
        *self = *self * rhs;
    }
}

impl std::ops::Neg for ModInt {
    type Output = ModInt;
    fn neg(self) -> Self::Output {
        ModInt(if self.0 == 0 {0} else {MOD - self.0})
    }
}

impl std::fmt::Display for ModInt {
    fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {
        write!(f, "{}", self.0)
    }
}

impl std::str::FromStr for ModInt {
    type Err = std::num::ParseIntError;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        let val = s.parse::<u32>()?;
        Ok(ModInt::new(val))
    }
}

impl From<usize> for ModInt {
    fn from(val: usize) -> ModInt {
        ModInt((val % MOD as usize) as u32)
    }
}

#[allow(dead_code)]
impl ModInt {
    pub fn new(n: u32) -> ModInt {
        ModInt(n % MOD)
    }
    pub fn zero() -> ModInt {
        ModInt(0)
    }
    pub fn one() -> ModInt {
        ModInt(1)
    }
    pub fn pow(self, mut n: u32) -> ModInt {
        let mut t = ModInt::one();
        let mut s = self;
        while n > 0 {
            if n & 1 == 1 {
                t *= s;
            }
            s *= s;
            n >>= 1;
        }
        t
    }
    pub fn inv(self) -> ModInt {
        assert!(self.0 > 0);
        self.pow(MOD - 2)
    }
}
// ---------- end ModInt ----------

use proconio::*;

fn run() {
    input! {
        k: usize,
    }
    let n = 3;
    let mut memo = vec![ModInt::zero(); k + 1];
    for i in (1..=k).rev() {
        let mut way = ModInt::from(k / i).pow(n);
        let mut j = 2 * i;
        while let Some(&v) = memo.get(j) {
            way -= v;
            j += i;
        }
        memo[i] = way;
    }
    let mut ans = ModInt::zero();
    for (i, c) in memo.into_iter().enumerate() {
        ans += ModInt::from(i) * c;
    }
    println!("{}", ans);
}

fn main() {
    run();
}


// -*- coding:utf-8-unix -*-

use proconio::input;
use num::integer::gcd;

fn main() {
    input! {
        n: u64
    }

    let mut r = 0;

    for i in 1..=n {
        for j in 1..n {
            for k in 1..n {
                r += gcd(gcd(i, j), k);
            }
        }
    }

    println!("{}", r);
}


// -*- coding:utf-8-unix -*-

use proconio::input;
use num::integer;

fn main() {
    input! {
        n: u64
    }

    let mut r = 0;

    for i in 1..=n {
        for j in 1..n {
            for k in 1..n {
                r += gcd(gcd(i, j), k);
            }
        }
    }

    println!("{}", r);
}


// -*- coding:utf-8-unix -*-

use proconio::input;
use num::integer::gcd;

fn main() {
    input! {
        n: u64
    }

    let mut r = 0;

    for i in 1..n {
        for j in 1..n {
            for k in 1..n {
                r += gcd(gcd(i, j), k);
            }
        }
    }

    println!("{}", r);
}


func gcd(_ a: Int, _ b: Int) -> Int {
    guard b != 0 else { return a }

    let r = a % b
    if r > b - r {
        return gcd(b, b - r)
    } else {
        return gcd(b, r)
    }
}

func gcd(_ a: Int, _ b: Int, _ c: Int) -> Int {
    gcd(gcd(a, b), c)
}

let N = Int(readLine()!)!

var sum0 = 0
for i in 1 ... N {
    guard i + 1 <= N else { continue }
    for j in i + 1 ... N {
        guard j + 1 <= N else { continue }
        for k in j + 1 ... N {
            sum0 += gcd(i, j, k)
        }
    }
}

var sum1 = 0
for i in 1 ... N {
    guard i + 1 <= N else { continue }
    for j in i + 1 ... N {
        sum1 += gcd(i, i, j)
        sum1 += gcd(i, j, j)
    }
}

var sum2 = 0
for i in 1 ... N {
    sum2 += gcd(i, i, i)
}

print(sum0 * 6 + sum1 * 3 + sum2)


// Your code here!
func gcd(_ a: Int, _ b: Int) -> Int {
   let r = a % b
   if r != 0 {
       return gcd(b, r)
   } else {
       return b
   }
}
var num = Int(readLine()!)!
var ans:Int = 0
for i in 1...num{
    for j in 1...num{
        for k in 1...num{
        var n:Int = 0
            n += gcd(i,j)
            ans += gcd(k,n)
        }
    }
}
print(ans)


// Sum of gcd of Tuples (Easy)
func gcd(_ a:Int, _ b:Int) -> Int {
  if a == 1 || b == 1 {
    return 1
  }
  if a == b {
    return a
  }
  return gcd(min(a, b), abs(b-a))
}

func main() {
  let n = Int(readLine()!)!
  var sum = 0
  for a in 1...n {
    for b in 1...n {
      for c in 1...n {
        sum += gcd(gcd(a,b), c)
      }
    }
  }
  print(sum)
}

main()


let K = Int(readLine()!)!
var res: Int = 0

for a in 1...K {
    for b in a...K {
        for c in b...K {
            if Set([a, b, c]).count == 3 {
                res += gcd(gcd(a, b), c) * 6
            } else if Set([a, b, c]).count == 2 {
                res += gcd(gcd(a, b), c) * 3
            } else {
                res += gcd(gcd(a, b), c)
            }
        }
    }
}
print(res)  // (๑•ૅㅁ•๑)


import Foundation

let main: () = {
    let K = 200 //getInt()
    var ans = 0
    for a in 1...K {
    for b in 1...K {
    for c in 1...K {
        ans += gcd(gcd(a, b), c)
    }}}
    print(ans)
}()

func gcd(_ a: Int, _ b: Int) -> Int { (b > 0) ? gcd(b, a % b) : a }

func getString() -> String { readLine()! }
func getInt() -> Int { Int(getString())! }
func getDouble() -> Double { Double(getString())! }


func gcd(_ a: Int, _ b: Int) -> Int {
    guard b != 0 else { return a }
    return gcd(b, a % b)
}

func gcda(_ s: [Int]) -> Int {
    guard !s.isEmpty else { return 0 }
    guard s.count > 1 else { return s.first! }

    var tmpS = s
    let first = tmpS.removeFirst()
    return tmpS.reduce(first) { gcd($0, $1) }
}

func memoize(_ f: @escaping ([Int]) -> Int) -> ([Int]) -> Int {
    var dic = [[Int] : Int]()
    return { nums in
        if let value = dic[nums.sorted()] {
            return value
        } else {
            let result = f(nums)
            dic[nums] = result
            return result
        }
    }
}

let m_gcda = memoize(gcda)

let k = Int(readLine()!)!

var results = [Int]()
for a in 1...k {
    for b in 1...k {
        for c in 1...k {
            results.append(m_gcda([a, b, c]))
        }
    }
}

let sum = results.reduce(into: 0) { $0 += $1 }
print(sum)


import * as fs from 'fs';

// main
function main(input: string[]) {
    // param
    var k: number = 0;
    var ans: number = 0;
    // init
    k = Number(input.shift());
    // solve
    var gcd: number[][] = new Array(201);
    for (var kx0 = 1; kx0 <= k; kx0++) {
        gcd[kx0] = new Array(201);
        for (var kx1 = 0; kx1 <= k; kx1++) {
            gcd[kx0][kx1] = Math_gcdArray([kx0, kx1]);
        }
    }
    for (var kx0 = 1; kx0 <= k; kx0++) {
        for (var kx1 = 1; kx1 <= k; kx1++) {
            for (var kx2 = 1; kx2 <= k; kx2++) {
                ans += gcd[gcd[kx0][kx1]][kx2];
            }
        }
    }
    // answer
    console.log(ans);
}

// graph lib
/*
function GRAPH_enumPattern(cur: number[], pat: number[][]): number[][] {
    var arr = [];
    for (var patx = 0; patx < pat.length; patx++) {
        var pos = [cur[0] + pat[patx][0], cur[1] + pat[patx][1]];
        arr.push(pos);
    }
    return arr;
}
*/

// math lib
function Math_max(arr: number[]): number { return arr.reduce((x, y) => Math.max(x, y)); }
function Math_min(arr: number[]): number { return arr.reduce((x, y) => Math.min(x, y)); }
function Math_gcd(): number {
    var ans = arguments[0];
    var f = (a: number, b: number): number => b ? f(b, a % b) : a
    for (var i = 1; i < arguments.length; i++) {
        ans = f(ans, arguments[i]);
    }
    return ans
};
function Math_gcdArray(values: number[]): number {
    var ans = values[0];
    var f = (a: number, b: number): number => b ? f(b, a % b) : a
    for (var i = 1; i < values.length; i++) {
        ans = f(ans, values[i]);
    }
    return ans
};
function Math_lcm(): number {
    var a = arguments
    var g = (n: number, m: number): number => m ? g(m, n % m) : n
    var l = (n: number, m: number): number => n * m / g(n, m)
    var ans = a[0]
    for (var i = 1; i < a.length; i++) {
        ans = l(ans, a[i])
    }
    return ans
}
function Math_lcmArray(values: number[]): number {
    var a = values
    var g = (n: number, m: number): number => m ? g(m, n % m) : n
    var l = (n: number, m: number): number => n * m / g(n, m)
    var ans = a[0]
    for (var i = 1; i < a.length; i++) {
        ans = l(ans, a[i])
    }
    return ans
}
function Math_primeList(value: number): number[] {
    var ans = [];
    var arr = new Array(value).fill(0);
    for (var i = 2; i < value; i++) {
        if (arr[i] == 0) {
            for (var j = i; j < value; j += i) {
                if (arr[j] == 0) arr[j] = i;
            }
        }
    }
    for (var i = 2; i < value; i++) {
        if (arr[i] == i) ans.push(i);
    }
    return ans;
}
function Math_primeFactor(p: number[], value: number): number[][] {
    var ans: number[][] = [];
    var valmax = value / 2;;
    for (var i = 0; i < p.length; i++) {
        var prime = p[i];
        if (valmax < prime) break;
        var count = 0;
        while (value % prime == 0) {
            value /= prime;
            count++;
        }
        if (count != 0) {
            ans.push([prime, count]);
        }
        if (value == 1) break;
    }
    return ans;
}

// union-find lib
/*
var g_uf_root: number[];
var g_uf_count: number[];
function UF_initRoot(num: number) {
    g_uf_root = new Array(num).fill(-1);
    g_uf_count = new Array(num).fill(1);
}
function UF_getRoot(index: number) {
    if (g_uf_root[index] < 0) {
        return index;
    } else {
        var work0: number = UF_getRoot(g_uf_root[index]);
        g_uf_root[index] = work0;
        return work0
    }
}
function UF_mergeRoot(a: number, b: number) {
    var root0: number = UF_getRoot(a);
    var root1: number = UF_getRoot(b);
    if (root0 == root1) return;
    if (root0 > root1) [root0, root1] = [root1, root0];
    g_uf_count[root0] += g_uf_count[root1];
    g_uf_count[root1] = 0;
    g_uf_root[root1] = root0;
}
*/

// entrypoint
function entrypoint() {
    try {
        // linux
        var input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            input = lines;
            main(input);
        });
    }
}
entrypoint();


class NormalInput {
  input: string[];
  pointer: number;
  constructor(raw: string) {
    this.input = raw.split(/ |\n/);
    this.pointer = 0;
  }
  int = (): number => {
    const ret = parseInt(this.input[this.pointer], 10);
    this.pointer++;
    return ret;
  };
  str = (): string => {
    const ret = this.input[this.pointer];
    this.pointer++;
    return ret;
  };
  strs = (length: number): string[] => {
    let ret: string[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.str());
    }
    return ret;
  };
  ints = (length: number): number[] => {
    let ret: number[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.int());
    }
    return ret;
  };
}
function rep(a: number, b: number) {
  let arr = [];
  for (let i = a; i < b; i++) arr.push(i);
  return arr;
}
function gcd(a: number, b: number) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
function Main({ int, str, strs, ints }: NormalInput) {
  const K = int();
  let sum = 0;
  for (let a = 0; a < K; a++)
    for (let b = 0; b < K; b++) {
      const gcdAB = gcd(a+1, b+1);
      for (let c = 0; c < K; c++) {
        const gcdABC = gcd(gcdAB, c+1);
        sum += gcdABC;
      }
    }
  console.log(sum);
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8")));


import * as fs from "fs";

const memo: Array<Array<number>> = [];
function gcd(x: number, y: number): number {
	if (y === 0) return x;
	if (memo[y] === undefined) memo[y] = [];
	if (memo[y][x] === undefined) {
		return memo[y][x] = gcd(y, x % y);
	}
	return memo[y][x];
}
const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const k = +input[0];

let result = 0;
for (let a = 1; a <= k; a++) {
	for (let b = 1; b <= k; b++) {
		const temp = gcd(Math.max(a, b), Math.min(a, b));
		for (let c = 1; c <= k; c++) {
			result += gcd(Math.max(temp, c), Math.min(temp, c));
		}
	}
}
console.log(result);


var input = process.argv[2];
var result = 0;
for (var a = 1; a <= input; a++) {
  for (var b = 1; b <= input; b++) {
    for (var c = 1; c <= input; c++) {
      // console.log(a + " " + b + " " + c);
      result += gcd(gcd(a, b), c);
    }
  }
}
console.log(result);

function gcd(a, b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a%b);
}


import * as fs from 'fs';

function gcd(...tuple: number[]) {
    const min = Math.min(...tuple);
    let gcd = 1;
    for (let i = 2; i <= min; i++) {
        let devides = true;
        for (let value of tuple) {
            if (value % i !== 0) {
                devides = false;
                break;
            }
        }
        if (devides) {
            gcd = i;
        }
    }
    return gcd;
}

function Main(input: string) {
    const constraintK = parseInt(input);
    let sum = 0;

    for (let a = 1; a <= constraintK; a++) {
        for (let b = 1; b <= constraintK; b++) {
            for (let c = 1; c <= constraintK; c++) {
                sum += gcd(a, b, c);
            }
        }
    }

    //output
    console.log(sum);
}

Main(fs.readFileSync("/dev/stdin", "utf8"));


import * as fs from "fs";

function main(lines: string[][]) {
  const number = parseInt(lines[0][0]);
  const numbers: number[] = [];
  for (let i = 1; i <= number; i++) {
    numbers.push(i);
  }

  const permutations: number[][] = [];
  numbers.forEach((n1) => {
    numbers.forEach((n2) => {
      numbers.forEach((n3) => {
        permutations.push([n1, n2, n3]);
      });
    });
  });

  const commonDivisor = (a: number, b: number) => (b > 0 ? commonDivisor(b, a % b) : a);
  const greatestCommonDivisor = (a: number, b: number, c: number): number => {
    let result = c;
    result = commonDivisor(result, b);
    result = commonDivisor(result, a);
    return result;
  };

  const gcds = permutations.map((p) => {
    const result = greatestCommonDivisor(p[0], p[1], p[2]);
    return result;
  });

  const point = gcds.reduce((prev, cur) => prev + cur, 0);
  console.log(point);
}

const lines = fs
  .readFileSync("/dev/stdin", "utf8")
  .split("\n")
  .map((l) => l.split(" "))
  .filter((input) => !(input.length === 1 && input[0] === ""));

main(lines);


def main():
    N = int( input())
    A = list( map( int, input().split()))
    B = [0]*(N+1)
    for a in A:
        B[a] += 1
    print("\n".join( map( str, B[1:])))
if __name__ == '__main__':
    main()


def main():
    N = int( input())
    A = list( map( int, input().split()))
    B = [0]*(N)
    for a in A:
        B[a-1] += 1
    print("\n".join( map( str, B)))
if __name__ == '__main__':
    main()


import sys

def resolve(in_, out):
    n = int(in_.readline())
    b = [0] * (n + 1)
    for a in map(int, in_.readline().split()):
        b[a] += 1
    out.write('\n'.join(map(str, b[1:])))

def main():
    resolve(sys.stdin.buffer, sys.stdout)

if __name__ == '__main__':
    main()


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

for i in range(1,N+1):
    count = a.count(i)
    print(count)


N = int(input())
A = list(map(int, input().split()))
assert len(A) == N - 1
count = [0 for i in range(len(A))]
for a in A:
  count[a] += 1
for n in range(N):
  print(count[n])


from collections import Counter
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
  print(Counter(a)[i])


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author iavanish
 */
public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CManagement solver = new CManagement();
        solver.solve(1, in, out);
        out.close();
    }

    static class CManagement {

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] countSubordinates = new int[n];
            for (int i = 1; i < n; i++) {
                countSubordinates[in.nextInt() - 1]++;
            }

            for (int i : countSubordinates) {
                out.println(i);
            }
        }

    }

    static class FastReader {

        private final int BUFFER_SIZE = 1 << 16;
        private final InputStream inputStream;
        private final byte[] buffer;
        private int bufferPointer;
        private int bytesRead;

        public FastReader() {
            this.inputStream = new DataInputStream(System.in);
            this.buffer = new byte[BUFFER_SIZE];
            this.bufferPointer = bytesRead = 0;
        }

        public FastReader(InputStream inputStream) {
            this.inputStream = inputStream;
            this.buffer = new byte[BUFFER_SIZE];
            this.bufferPointer = bytesRead = 0;
        }

        public FastReader(String fileName) {
            try {
                this.inputStream = new DataInputStream(new FileInputStream(fileName));
                this.buffer = new byte[BUFFER_SIZE];
                this.bufferPointer = bytesRead = 0;
            } catch (FileNotFoundException e) {
                throw new RuntimeException(e);
            }
        }

        public int nextInt() {
            int nextInt = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean negative = (c == '-');
            if (negative) {
                c = read();
            }
            do {
                nextInt = nextInt * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (negative) {
                return -nextInt;
            }
            return nextInt;
        }

        private void fillBuffer() {
            try {
                bytesRead = inputStream.read(buffer, bufferPointer = 0, BUFFER_SIZE);
                if (bytesRead == -1) {
                    buffer[0] = -1;
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        private byte read() {
            if (bufferPointer == bytesRead) {
                fillBuffer();
            }
            return buffer[bufferPointer++];
        }

    }

}


import java.math.*;
import java.io.*;
import java.util.*;
import java.awt.*;

public class Main implements Runnable {
    @Override
    public void run() {
        try {
            new Solver().solve();
            System.exit(0);
        } catch (Exception | Error e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    public static void main(String[] args) {
        //new Thread(null, new Main(), "Solver", 1l << 25).start();
        new Main().run();
    }
}

class Solver {
    final Helper hp;
    final int MAXN = 1000_006;
    final long MOD = (long) 1e9 + 7;

    final Timer timer;
    final TimerTask task;

    Solver() {
        hp = new Helper(MOD, MAXN);
        hp.initIO(System.in, System.out);

        timer = new Timer();
        task = new TimerTask() {
            @Override
            public void run() {
                try {
                    hp.flush();
                    System.exit(0);
                } catch (Exception e) {
                }
            }
        };
        //timer.schedule(task, 4700);
    }

    void solve() throws Exception {
        int i, j, k;
        boolean testCases = false;

        int tc = testCases ? hp.nextInt() : 1;
        for (int tce = 1; tce <= tc; tce++) {
            int N = hp.nextInt();
            int[] A = hp.getIntArray(N - 1);

            int[] childCount = new int[N];
            for (i = 0; i < N - 1; ++i) {
                ++childCount[A[i] - 1];
            }

            for (int itr : childCount) hp.println(itr);
        }

        timer.cancel();
        hp.flush();
    }

}

class Helper {
    final long MOD;
    final int MAXN;
    final Random rnd;

    public Helper(long mod, int maxn) {
        MOD = mod;
        MAXN = maxn;
        rnd = new Random();
    }

    public static int[] sieve;
    public static ArrayList<Integer> primes;

    public void setSieve() {
        primes = new ArrayList<>();
        sieve = new int[MAXN];
        int i, j;
        for (i = 2; i < MAXN; ++i)
            if (sieve[i] == 0) {
                primes.add(i);
                for (j = i; j < MAXN; j += i) {
                    sieve[j] = i;
                }
            }
    }

    public static long[] factorial;

    public void setFactorial() {
        factorial = new long[MAXN];
        factorial[0] = 1;
        for (int i = 1; i < MAXN; ++i) factorial[i] = factorial[i - 1] * i % MOD;
    }

    public long getFactorial(int n) {
        if (factorial == null) setFactorial();
        return factorial[n];
    }

    public long ncr(int n, int r) {
        if (r > n) return 0;
        if (factorial == null) setFactorial();
        long numerator = factorial[n];
        long denominator = factorial[r] * factorial[n - r] % MOD;
        return numerator * pow(denominator, MOD - 2, MOD) % MOD;
    }

    public long[] getLongArray(int size) throws Exception {
        long[] ar = new long[size];
        for (int i = 0; i < size; ++i) ar[i] = nextLong();
        return ar;
    }

    public int[] getIntArray(int size) throws Exception {
        int[] ar = new int[size];
        for (int i = 0; i < size; ++i) ar[i] = nextInt();
        return ar;
    }

    public String[] getStringArray(int size) throws Exception {
        String[] ar = new String[size];
        for (int i = 0; i < size; ++i) ar[i] = next();
        return ar;
    }

    public String joinElements(long... ar) {
        StringBuilder sb = new StringBuilder();
        for (long itr : ar) sb.append(itr).append(" ");
        return sb.toString().trim();
    }

    public String joinElements(int... ar) {
        StringBuilder sb = new StringBuilder();
        for (int itr : ar) sb.append(itr).append(" ");
        return sb.toString().trim();
    }

    public String joinElements(String... ar) {
        StringBuilder sb = new StringBuilder();
        for (String itr : ar) sb.append(itr).append(" ");
        return sb.toString().trim();
    }

    public String joinElements(Object... ar) {
        StringBuilder sb = new StringBuilder();
        for (Object itr : ar) sb.append(itr).append(" ");
        return sb.toString().trim();
    }

    public long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    public int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    public long max(long... ar) {
        long ret = ar[0];
        for (long itr : ar) ret = Math.max(ret, itr);
        return ret;
    }

    public int max(int... ar) {
        int ret = ar[0];
        for (int itr : ar) ret = Math.max(ret, itr);
        return ret;
    }

    public long min(long... ar) {
        long ret = ar[0];
        for (long itr : ar) ret = Math.min(ret, itr);
        return ret;
    }

    public int min(int... ar) {
        int ret = ar[0];
        for (int itr : ar) ret = Math.min(ret, itr);
        return ret;
    }

    public long sum(long... ar) {
        long sum = 0;
        for (long itr : ar) sum += itr;
        return sum;
    }

    public long sum(int... ar) {
        long sum = 0;
        for (int itr : ar) sum += itr;
        return sum;
    }

    public void shuffle(Integer[] ar) {
        int r;
        for (int i = 0; i < ar.length; ++i) {
            r = rnd.nextInt(ar.length);
            if (r != i) {
                ar[i] ^= ar[r];
                ar[r] ^= ar[i];
                ar[i] ^= ar[r];
            }
        }
    }

    public void shuffle(long[] ar) {
        int r;
        for (int i = 0; i < ar.length; ++i) {
            r = rnd.nextInt(ar.length);
            if (r != i) {
                ar[i] ^= ar[r];
                ar[r] ^= ar[i];
                ar[i] ^= ar[r];
            }
        }
    }

    public void reverse(int[] ar) {
        int r;
        for (int i = 0; i < ar.length; ++i) {
            r = ar.length - 1 - i;
            if (r > i) {
                ar[i] ^= ar[r];
                ar[r] ^= ar[i];
                ar[i] ^= ar[r];
            }
        }
    }

    public void reverse(long[] ar) {
        int r;
        for (int i = 0; i < ar.length; ++i) {
            r = ar.length - 1 - i;
            if (r > i) {
                ar[i] ^= ar[r];
                ar[r] ^= ar[i];
                ar[i] ^= ar[r];
            }
        }
    }

    public long pow(long base, long exp, long MOD) {
        base %= MOD;
        long ret = 1;
        while (exp > 0) {
            if ((exp & 1) == 1) ret = ret * base % MOD;
            base = base * base % MOD;
            exp >>= 1;
        }
        return ret;
    }

    static final int BUFSIZE = 1 << 20;
    static byte[] buf;
    static int index, total;
    static InputStream in;
    static BufferedWriter bw;

    public void initIO(InputStream is, OutputStream os) {
        try {
            in = is;
            bw = new BufferedWriter(new OutputStreamWriter(os));
            buf = new byte[BUFSIZE];
        } catch (Exception e) {
        }
    }

    public void initIO(String inputFile, String outputFile) {
        try {
            in = new FileInputStream(inputFile);
            bw = new BufferedWriter(new OutputStreamWriter(
                    new FileOutputStream(outputFile)));
            buf = new byte[BUFSIZE];
        } catch (Exception e) {
        }
    }

    private int scan() throws Exception {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0)
                return -1;
        }
        return buf[index++];
    }

    public String next() throws Exception {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan())
            sb.append((char) c);
        return sb.toString();
    }

    public int nextInt() throws Exception {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+')
            c = scan();
        for (; c >= '0' && c <= '9'; c = scan())
            val = (val << 3) + (val << 1) + (c & 15);
        return neg ? -val : val;
    }

    public long nextLong() throws Exception {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+')
            c = scan();
        for (; c >= '0' && c <= '9'; c = scan())
            val = (val << 3) + (val << 1) + (c & 15);
        return neg ? -val : val;
    }

    public void print(Object a) throws Exception {
        bw.write(a.toString());
    }

    public void printsp(Object a) throws Exception {
        print(a);
        print(" ");
    }

    public void println() throws Exception {
        bw.write("\n");
    }

    public void println(Object a) throws Exception {
        print(a);
        println();
    }

    public void flush() throws Exception {
        bw.flush();
    }
}


import java.io.*;
import java.util.*;

public class Main {
	static InputStream is;
	static PrintWriter out;
	static String INPUT = "";

	static final long mod = (long) 1e9 + 7;
	static final int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
	static final int[] dx8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int inf = Integer.MAX_VALUE / 3;
	static final long linf = Long.MAX_VALUE / 3;
	static final double dinf = Double.MAX_VALUE / 3;

	static void solve() {
		int n = ni();
		int ans[] = new int[n];
		for(int i=0;i<n-1;i++) {
			int a = ni() - 1;
			ans[a]++;
		}
		for(int i=0;i<n;i++) {
			out.println(ans[i]);
		}
	}

	//libraries
	/**
	*	upperBound
	*	@param List<T> 探索対象のList
	*   @param T 探索値
	*	@return xよりも大きい要素のうち、indexが最小の物のindex
	*/
	static <T> int upperBound(List<T> ls, T x) throws RuntimeException {
		if (ls.size() == 0)
			return -1;
		if (ls.get(0) instanceof Integer) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) > 0 ? 1 : -1);
		} else if (ls.get(0) instanceof Long) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) > 0 ? 1 : -1);
		} else if (ls.get(0) instanceof Double) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) > 0 ? 1 : -1);
		} else {
			System.err.println(
					String.format("%s:数値でないリストを二分探索しています。", Thread.currentThread().getStackTrace()[1].getMethodName()));
			throw new RuntimeException();
		}
	}

	/**
	*	lowerBound
	*	@param List<T> 探索対象のList
	*   @param T 探索値
	*	@return x以上の要素のうち、indexが最小の物のindex
	*/
	static <T> int lowerBound(List<T> ls, T x) {
		if (ls.size() == 0)
			return -1;
		if (ls.get(0) instanceof Integer) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) >= 0 ? 1 : -1);
		} else if (ls.get(0) instanceof Long) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) >= 0 ? 1 : -1);
		} else if (ls.get(0) instanceof Double) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) >= 0 ? 1 : -1);
		} else {
			System.err.println(
					String.format("%s:数値でないリストを二分探索しています。", Thread.currentThread().getStackTrace()[1].getMethodName()));
			throw new RuntimeException();
		}
	}

	/**
	 *	rupperBound
	 *  @memo 降順ソートされたListに対して利用する
	 *	@param List<T> 探索対象のList
	 *  @param T 探索値
	 *	@return xよりも大きい要素のうち、indexが最小の物のindex
	 */
	static <T> int rupperBound(List<T> ls, T x) throws RuntimeException {
		if (ls.size() == 0)
			return -1;
		if (ls.get(0) instanceof Integer) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) < 0 ? 1 : -1);
		} else if (ls.get(0) instanceof Long) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) < 0 ? 1 : -1);
		} else if (ls.get(0) instanceof Double) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) < 0 ? 1 : -1);
		} else {
			System.err.println(
					String.format("%s:数値でないリストを二分探索しています。", Thread.currentThread().getStackTrace()[1].getMethodName()));
			throw new RuntimeException();
		}
	}

	/**
	 *	rlowerBound
	 *  @memo 降順ソートされたListに対して利用する
	 *	@param List<T> 探索対象のList
	 *  @param T 探索値
	 *	@return x以上の要素のうち、indexが最小の物のindex
	 */
	static <T> int rlowerBound(List<T> ls, T x) {
		if (ls.size() == 0)
			return -1;
		if (ls.get(0) instanceof Integer) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) <= 0 ? 1 : -1);
		} else if (ls.get(0) instanceof Long) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) <= 0 ? 1 : -1);
		} else if (ls.get(0) instanceof Double) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) <= 0 ? 1 : -1);
		} else {
			System.err.println(
					String.format("%s:数値でないリストを二分探索しています。", Thread.currentThread().getStackTrace()[1].getMethodName()));
			throw new RuntimeException();
		}
	}

	/**
	*	upperBound
	*	@param T[] 探索対象の配列
	*   @param T 探索値
	*	@return xよりも大きい要素のうち、indexが最小の物のindex
	*/
	static <T> int upperBound(T[] ar, T x) {
		if (ar instanceof Integer[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) > 0 ? 1 : -1);
		} else if (ar instanceof Long[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) > 0 ? 1 : -1);
		} else if (ar instanceof Double[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) > 0 ? 1 : -1);
		} else {
			System.err.println(
					String.format("%s:数値でない配列を二分探索しています。", Thread.currentThread().getStackTrace()[1].getMethodName()));
			throw new RuntimeException();
		}
	}

	/**
	*	lowerBound
	*	@param T[] 探索対象の配列
	*   @param T 探索値
	*	@return x以上の要素のうち、indexが最小の物のindex
	*/
	static <T> int lowerBound(T[] ar, T x) {
		if (ar instanceof Integer[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) >= 0 ? 1 : -1);
		} else if (ar instanceof Long[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) >= 0 ? 1 : -1);
		} else if (ar instanceof Double[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) >= 0 ? 1 : -1);
		} else {
			System.err.println(
					String.format("%s:数値でない配列を二分探索しています。", Thread.currentThread().getStackTrace()[1].getMethodName()));
			throw new RuntimeException();
		}
	}

	/**
	 *	rupperBound
	 *  @memo 降順ソートされた配列に対して利用する
	 *	@param T[] 探索対象の配列
	 *  @param T 探索値
	 *	@return xよりも大きい要素のうち、indexが最小の物のindex
	 */
	static <T> int rupperBound(T[] ar, T x) {
		if (ar instanceof Integer[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) < 0 ? 1 : -1);
		} else if (ar instanceof Long[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) < 0 ? 1 : -1);
		} else if (ar instanceof Double[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) < 0 ? 1 : -1);
		} else {
			System.err.println(
					String.format("%s:数値でない配列を二分探索しています。", Thread.currentThread().getStackTrace()[1].getMethodName()));
			throw new RuntimeException();
		}
	}

	/**
	 *	rlowerBound
	 *  @memo 降順ソートされた配列に対して利用する
	 *	@param T[] 探索対象の配列
	 *  @param T 探索値
	 *	@return x以上の要素のうち、indexが最小の物のindex
	 */
	static <T> int rlowerBound(T[] ar, T x) {
		if (ar instanceof Integer[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) <= 0 ? 1 : -1);
		} else if (ar instanceof Long[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) <= 0 ? 1 : -1);
		} else if (ar instanceof Double[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) <= 0 ? 1 : -1);
		} else {
			System.err.println(
					String.format("%s:数値でない配列を二分探索しています。", Thread.currentThread().getStackTrace()[1].getMethodName()));
			throw new RuntimeException();
		}
	}

	static int[] concat(int x, int arr[]) {
		int ret[] = new int[arr.length + 1];
		System.arraycopy(arr, 0, ret, 1, ret.length - 1);
		ret[0] = x;
		return ret;
	}

	static int[] concat(int arr[], int x) {
		int ret[] = new int[arr.length + 1];
		System.arraycopy(arr, 0, ret, 0, ret.length - 1);
		ret[ret.length - 1] = x;
		return ret;
	}

	static long[] concat(long x, long arr[]) {
		long ret[] = new long[arr.length + 1];
		System.arraycopy(arr, 0, ret, 1, ret.length - 1);
		ret[0] = x;
		return ret;
	}

	static long[] concat(long arr[], long x) {
		long ret[] = new long[arr.length + 1];
		System.arraycopy(arr, 0, ret, 0, ret.length - 1);
		ret[ret.length - 1] = x;
		return ret;
	}

	static long max(long x, long y) {
		return Math.max(x, y);
	}

	static long min(long x, long y) {
		return Math.min(x, y);
	}

	static long max(long x, long y, long z) {
		x = Math.max(x, y);
		x = Math.max(x, z);
		return x;
	}

	static long min(long x, long y, long z) {
		x = Math.min(x, y);
		x = Math.min(x, z);
		return x;
	}

	static double max(double x, double y) {
		return Math.max(x, y);
	}

	static double min(double x, double y) {
		return Math.min(x, y);
	}

	static double max(double x, double y, double z) {
		x = Math.max(x, y);
		x = Math.max(x, z);
		return x;
	}

	static double min(double x, double y, double z) {
		x = Math.min(x, y);
		x = Math.min(x, z);
		return x;
	}

	static void sort(int[] ar) {
		Arrays.sort(ar);
	}

	static void sort(long[] ar) {
		Arrays.sort(ar);
	}

	static void sort(double[] ar) {
		Arrays.sort(ar);
	}

	static void rsort(int[] ar) {
		Arrays.sort(ar);
		int len = ar.length;
		for (int i = 0; i < len / 2; i++) {
			int tmp = ar[i];
			ar[i] = ar[len - 1 - i];
			ar[len - 1 - i] = tmp;
		}
	}

	static void rsort(long[] ar) {
		Arrays.sort(ar);
		int len = ar.length;
		for (int i = 0; i < len / 2; i++) {
			long tmp = ar[i];
			ar[i] = ar[len - 1 - i];
			ar[len - 1 - i] = tmp;
		}
	}

	static void rsort(double[] ar) {
		Arrays.sort(ar);
		int len = ar.length;
		for (int i = 0; i < len / 2; i++) {
			double tmp = ar[i];
			ar[i] = ar[len - 1 - i];
			ar[len - 1 - i] = tmp;
		}
	}

	static void fill(int arr[], int x) {
		Arrays.fill(arr, x);
	}

	static void fill(long arr[], long x) {
		Arrays.fill(arr, x);
	}

	static void fill(double arr[], double x) {
		Arrays.fill(arr, x);
	}

	static void fill(int arr[][], int x) {
		for (int i = 0; i < arr.length; i++)
			Arrays.fill(arr[i], x);
	}

	static void fill(long arr[][], long x) {
		for (int i = 0; i < arr.length; i++)
			Arrays.fill(arr[i], x);
	}

	static void fill(double arr[][], double x) {
		for (int i = 0; i < arr.length; i++)
			Arrays.fill(arr[i], x);
	}

	//MOD culc
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}

	public static void main(String[] args) throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	//input
	private static byte[] inbuf = new byte[1024];
	static int lenbuf = 0, ptrbuf = 0;

	private static int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private static boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private static int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	@SuppressWarnings("unused")
	private static double nd() {
		return Double.parseDouble(ns());
	}

	@SuppressWarnings("unused")
	private static char nc() {
		return (char) skip();
	}

	private static String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private static char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	@SuppressWarnings("unused")
	private static char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	@SuppressWarnings("unused")
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private static int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	@SuppressWarnings("unused")
	private static long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

}


import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int t=0;
		int b[]=new int[a-1];
		for(int i=0;i<a-1;i++) {
			int k =sc.nextInt();
			b[k+1]++;
		}
		for(int j=0;j<a-1;j++) {
			System.out.println(b[j]);
		}
		System.out.println(0);

	}

}


import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int t=0;
		int b[]=new int[a-1];
		for(int i=0;i<a-1;i++) {
			int k =sc.nextInt();
			for(int j=0;j<a-1;j++) {
				if(j+1==k) {
					b[j]++;
				}
			}
		}
		for(int j=0;j<a-1;j++) {
			System.out.println(b[j]);
		}
		System.out.println(0);

	}

}


import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int t=0;
		int b[]=new int[a];
		for(int i=0;i<a-1;i++) {
			int k =sc.nextInt();
			for(int j=0;j<a;j++) {
				if(j+1==k) {
					b[j]++;
				}
				System.out.println(b[j]);
			}
		}

	}

}


#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 440000, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (72 - dig >> 3);
	return tmp;
}
char* di = cn;
inline void putint(int X) {
	if (X < 10) {
		*di++ = '0' + X;
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

int A[200001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	int N = getint();
	rep(i, N - 1) A[getint()]++;

	rep1(i, N) putint(A[i]);

	fwrite(cn, 1, di - cn, stdout);

	Would you please return 0;
}


#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1400000;
char cn[CM], * ci = cn, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (72 - dig >> 3);
	return tmp;
}
char* di = cn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

int A[200001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	fread(cn, 1, CM, stdin);
	int N = getint();
	rep(i, N - 1) A[getint()]++;

	rep1(i, N) putint(A[i]);

	fwrite(cn, 1, di - cn, stdout);

	Would you please return 0;
}


#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1400000;
char cn[CM], * ci = cn, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (72 - dig >> 3);
	return tmp;
}
char* di = cn;
inline void putint(int X) {
	if (X < 10) {
		*di++ = '0' + X;
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

int A[200001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	fread(cn, 1, CM, stdin);
	int N = getint();
	rep(i, N - 1) A[getint()]++;

	rep1(i, N) putint(A[i]);

	fwrite(cn, 1, di - cn, stdout);

	Would you please return 0;
}


#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define int long long int
#define vi vector<int>
#define vvi vector < vi >
#define pii pair<int,int>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define tr(k,st,en) for(int k = st; k <= en ; k++)
#define trb(k,en,st) for(int k = en; k >= st ; k--)
using namespace std;

//int n = 2;
//
//void add_self(int& a, int b){
//    a += b;
//    if (a >= mod) {
//        a-=mod;
//    }
//}
//
//int mul(int a, int b){
//    int c = a*b;
//    return c%mod;
//}
//
//struct M {
//    vector<vector<int>> t;
//    M(){
//        t.resize(n, vector<int>(n));
//    }
//    M operator * (M& b){
//        M c;
//        tr(i,0, n-1){
//            tr(j,0,n-1){
//                tr(k,0,n-1){
//                    add_self(c.t[i][j] , mul(t[i][k] ,b.t[k][j]));
//                }
//            }
//        }
//        return c;
//    }
//};
//M power(M x, int k){
//    M ans;
//    tr(i,0,n-1){
//        ans.t[i][i] = 1;
//    }
//    while (k) {
//        if (k%2) {
//            ans = ans * x;
//        }
//        x = x*x;
//        k/=2;
//    }
//    return ans;
//}

int32_t main()
{
    std::ios::sync_with_stdio(false);
    map<int,int> freq;
    int n,temp;
    cin>>n;
    tr(i,1,n-1){
        cin>>temp;
        freq[temp]++;
    }
    tr(i,1,n){
        auto it = freq.lower_bound(i);
        cout<< (it == freq.end() ? 0 : it->second)<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define int long long int
#define vi vector<int>
#define vvi vector < vi >
#define pii pair<int,int>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define tr(k,st,en) for(int k = st; k <= en ; k++)
#define trb(k,en,st) for(int k = en; k >= st ; k--)
using namespace std;

//int n = 2;
//
//void add_self(int& a, int b){
//    a += b;
//    if (a >= mod) {
//        a-=mod;
//    }
//}
//
//int mul(int a, int b){
//    int c = a*b;
//    return c%mod;
//}
//
//struct M {
//    vector<vector<int>> t;
//    M(){
//        t.resize(n, vector<int>(n));
//    }
//    M operator * (M& b){
//        M c;
//        tr(i,0, n-1){
//            tr(j,0,n-1){
//                tr(k,0,n-1){
//                    add_self(c.t[i][j] , mul(t[i][k] ,b.t[k][j]));
//                }
//            }
//        }
//        return c;
//    }
//};
//M power(M x, int k){
//    M ans;
//    tr(i,0,n-1){
//        ans.t[i][i] = 1;
//    }
//    while (k) {
//        if (k%2) {
//            ans = ans * x;
//        }
//        x = x*x;
//        k/=2;
//    }
//    return ans;
//}

int32_t main()
{
    std::ios::sync_with_stdio(false);
    map<int,int> freq;
    int n,temp;
    cin>>n;
    tr(i,1,n-1){
        cin>>temp;
        freq[temp] ++;
    }
    tr(i,0,n-1){
        auto it = freq.upper_bound(i);
        cout<< (it == freq.end() ? 0 : it->second)<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
#define coa cout << ans << endl
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;

int main(){
    int n;
    cin >> n;
    // vector<int> buka(n, 0);
    int buka[n];
    rep(i, n - 1){
        int tmp;
        cin >> tmp;
        tmp--;
        buka[tmp]++;
    }

    rep(i, n){
        cout << buka[i] << endl;
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main(){
	int n, num;
	int sum_a = 0;
	int *p;

	scanf("%d\n", &n);
	p = malloc(n * sizeof(int));
	for(int i=0; i<n; i++){
		p[i]=0;
	}
	num = n-1;
	while (0<num){
		int up_no = 0;
		char c = getchar();
		while((c!=' ') && (c!=10)){
			up_no *= 10;
			up_no += c - '0';
			c = getchar();
		}
		p[up_no-1]++;
		num--;
	}
	for(int i=0; i<n; i++){
		printf("%d\n", p[i]);
	}
	return (0);
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
	int N,*A,a;
	int i;
	char str[10000000];

	fgets(str, sizeof(str), stdin);
	N=atoi(strtok(str," "));

	A = (int*)calloc(N,sizeof(int));

	fgets(str, sizeof(str), stdin);
	a=atoi(strtok(str," "))-1;

	A[a]+=1;
	for(i=1;i<(N-1);i++){
		a=atoi(strtok(NULL," "))-1;
		A[a]+=1;
	}

	for(i=0;i<N;i++){
		printf("%d\n",A[i]);
	}

	free(A);

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
    int n,a[500000]={},i,sum[500000]={};
    char token[10000000]={};
    fgets(token, sizeof(token), stdin);
    n=atoi(token);
    fgets(token, sizeof(token), stdin);
    a[0]=atoi(strtok(token, " "));
    for (i=1; i<n-1; i++) a[i]=atoi(strtok(NULL, " "));
    for (i=0; i<n-1; i++) sum[a[i]]++;
    for (i=1; i<=n; i++) printf("%d\n",sum[i]);
    return 0;
}


#include <stdio.h>
#define true 1

int main(void)
{
    int n=0;
    int boss[200001]={};
    int bossNum[200001]={};
    scanf("%d",&n);
    for(int i=2;i<=n;i++){
        scanf("%d",&boss[i]);
        bossNum[boss[i]]+=1;
    }

    for(int i=1;i<=n;i++){
        printf("%d",bossNum[i]);
    }

    return 0;
}


#include <stdio.h>

int main(){
  int n, t;
  scanf("%d", &n);
  int a[100002]={0};
  for(int i=0; i<n-1; i++){
    scanf("%d", &t);
    a[t-1]++;
  }
  for(int i=0; i<n; i++) printf("%d\n", a[i]);
}


#include <stdio.h>

int main(){
  int n, t;
  scanf("%d", &n);
  int a[n]={0};
  for(int i=0; i<n-1; i++){
    scanf("%d", &t);
    a[t-1]++;
  }
  for(int i=0; i<n; i++) printf("%d\n", a[i]);
}


inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
N = inp.shift() * 1
l = inp.shift().split(" ")
a = new Array(N)
for (i=0; i<N; i++) {
    a[i] = 0
    a[l[i] - 1] = a[l[i] - 1] + 1
}
console.log(a.join("\n"))


const Main = input => {
  const sp = input.split('\n');
  const N = Number(sp[0]);
  const A_list = sp[1].split(' ').map(e => Number(e));

  const list = new Array(N).fill(0);

  for(let i=0; i<A_list.length; i++) list[A_list[i]-1]++;

  console.log(list.join('\n'));
};

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
/*Main(`5
1 1 2 2`);
Main(`10
1 1 1 1 1 1 1 1 1`)
Main(`7
1 2 3 4 5 6`)*/


var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
	var list = nextIntArray();
	var output = new Array(N).fill(0);
	for(var i = 0; i < N - 1; i++){
		output[list[i] - 1]++;
	}
	myout(myconv(output,9));
}


const Main = (input) => {
  const tmp = input.trim().split('\n')
  const employees = parseInt(tmp[0])
  const subordinateArray = tmp[1].split(' ')

  const subordinateCount = {}

  const distinctSubordinate = subordinateArray.filter(
    (x, i, self) => self.indexOf(x) === i
  )

  subordinateArray.forEach((elem) => {
    subordinateCount[elem] = subordinateCount[elem]
      ? subordinateCount[elem] + 1
      : 1
  })

  let result = []
  distinctSubordinate.forEach((elem) => {
    return result.push(subordinateCount[elem])
  })

  const zeroCount = employees - distinctSubordinate.length

  if (zeroCount > 0) {
    for (let index = 0; index < zeroCount; index++) {
      result.push(0)
    }
  }

  result = result.join('\n')

  console.log(result)
  return result
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))


'use strict';
function main(input) {
  const arr = input.trim().split('\n');
  const a = arr[1].split(' ').map(x => Number(x));
  let count = 0;

  for (let i = 1; i < a.length + 2; i ++) {
    for (let j = 0; j < a.length; j ++) {
      if (a[j] === i) {
        count ++;
      }
    }
    console.log(count);
    count = 0;
  }

}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
    console.log(x);
}

let inputString = "";
let currentLine = 0;

process.stdin.on("data", inputStdin => {
    inputString += inputStdin;
});
process.stdin.on("end", () => {
    inputString = inputString.split("\n");
    main();
});
function readline() {
    return inputString[currentLine++];
}

//-----------main fucntion-----------

function main() {
    var input = parseInt(readline())
    var a = readline().split(" ").map(x => parseInt(x))
    var n = []
    n.push(input - 1)
    n.length = input
    n.fill(0, 1)
    print(n.join('\n'))
}


package main

import (
	"bufio"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	xs := make([]int, n+1)
	for i := 1; i < n; i++ {
		a := scanInt()
		xs[a]++
	}

	var wr = bufio.NewWriter(os.Stdout)
	for i := 1; i <= n; i++ {
		wr.WriteString(strconv.Itoa(xs[i]) + "\n")
	}
	wr.Flush()
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	v := make([]int, n)
	var a int
	for i := 1; i < n; i++ {
		sc.Scan()
		a, _ = strconv.Atoi(sc.Text())
		v[a-1]++
	}
	w := bufio.NewWriter(os.Stdout)
	for _, e := range v {
		fmt.Fprintln(w, e)
	}
	w.Flush()
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 1024
	maxBufSize     = 1e6
)

var (
	scanner = bufio.NewScanner(os.Stdin)
	writer  = bufio.NewWriterSize(os.Stdout, 1000000)
)

func main() {
	scanner.Split(bufio.ScanWords)
	// scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer writer.Flush()
	n := scanInt()
	m := make([]int, n)
	for i := 0; i < (n - 1); i++ {
		m[scanInt()-1]++
	}

	for i := 0; i < n; i++ {
		fmt.Fprintf(writer, "%v\n", m[i])
	}
}

func scanInt() int {
	i, _ := strconv.Atoi(scanString())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanString(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanString() string {
	scanner.Scan()
	return scanner.Text()
}

func scanStrings(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanString()
	}
	return s
}


package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%d", &N)

	A := make([]int, N-1)
	for i := 0; i < N-1; i++ {
		fmt.Scanf("%d", &A[i])
	}
	for i := 1; i <= N; i++ {
		count := 0
		for j := 0; j < N-1; j++ {
			if i == A[j] {
				count++
			}
		}
		fmt.Println(count)
	}
}


package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	nums := make([]int, n)
	for l:=0; l<n-1; l++{
		fmt.Scan(&nums[l])
	}

	count_map := make(map[int]int)

	for i:=1; i<=n; i++{
		for m:=0; m<n-1; m++{
			if i == nums[m]{
				count_map[i] ++
			}
		}
		fmt.Println(count_map[i])
	}

}


package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	ma := make(map[int]int, n)
	for i := 2; i < n+1; i++ {
		var temp int
		fmt.Scan(&temp)
		ma[temp-1]++
	}

	for i := 0; i < n; i++ {
		if i < len(ma) {
			fmt.Println(ma[i])
		} else {
			fmt.Println(0)
		}
	}
}


n = gets.to_s.to_i
a = gets.to_s.split.map{|i| i.to_i }

ans = [0] * (n + 1)

a.each{|t| ans[t] += 1 }
ans.shift

p *ans


N = gets.to_i
A = gets.split.map &:to_i

ans = [0] * (N + 1)

A.each{|a|
  ans[a] += 1
}
ans.shift
p *ans


N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)

ans = Array.new(N+1, 0)
A.each{|a| ans[a] += 1}

ans.shift
puts ans * "\n"


N = gets.to_i
ary = gets.strip.split(nil).map(&:to_i)
png = []
i = 1
while i <= N do
  png[i-1] = ary.count(i)
  i += 1
end
puts png


n = gets.to_i
array = gets.split(" ").map(&:to_i)

(1..n).each do |n|
  puts array.count(n)
end


n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)

ans = Array.new(n){0}
a.each do |i|
  ans[a[i]-1] += 1
end
ans.each do |i|
  puts i
end


use std::io::*;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

pub fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();
    let a = i.read_vec::<usize>(n - 1);

    let mut ans = vec![0; n];
    for a in a {
        ans[a - 1] += 1;
    }
    for &c in &ans {
        writeln!(o, "{}", c).unwrap();
    }
}

pub mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        b: Vec<u8>,
    }
    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                b: Vec::new(),
            }
        }
        pub fn read_word(&mut self) -> &[u8] {
            self.b.clear();
            let mut consume = 0;
            loop {
                self.r.consume(consume);
                let b = self.r.fill_buf().unwrap();
                assert!(b.len() != 0);
                if let Some(p) = b.iter().position(|&x| x == b' ' || x == b'\n') {
                    self.b.extend_from_slice(&b[..p]);
                    consume = p + 1;
                    break;
                }
                self.b.extend_from_slice(b);
                consume = b.len();
            }
            self.r.consume(consume);
            &self.b
        }
        pub fn read_word_str(&mut self) -> &str {
            unsafe { std::str::from_utf8_unchecked(self.read_word()) }
        }

        pub fn read_line(&mut self) -> &[u8] {
            self.b.clear();
            self.r.read_until(b'\n', &mut self.b).unwrap();
            if self.b.last() == Some(&b'\n') {
                &self.b[..self.b.len() - 1]
            } else {
                &self.b
            }
        }
        pub fn read_line_str(&mut self) -> &str {
            unsafe { std::str::from_utf8_unchecked(self.read_line()) }
        }

        pub fn read<T: CpIn>(&mut self) -> T {
            T::read_from(self)
        }

        pub fn read_vec<T: CpIn>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.read()).collect()
        }
        pub fn read_iter<'a, T: CpIn>(&'a mut self, n: usize) -> CpIter<'a, R, T> {
            CpIter {
                r: self,
                n: n,
                _pd: Default::default(),
            }
        }
    }
    pub struct CpIter<'a, R: BufRead + 'a, T> {
        r: &'a mut CpReader<R>,
        n: usize,
        _pd: std::marker::PhantomData<fn() -> T>,
    }
    impl<'a, R: BufRead, T: CpIn> Iterator for CpIter<'a, R, T> {
        type Item = T;
        fn next(&mut self) -> Option<T> {
            if self.n == 0 {
                None
            } else {
                self.n -= 1;
                Some(self.r.read())
            }
        }
    }

    pub trait CpIn {
        fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self;
    }

    impl CpIn for u64 {
        fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self {
            read_u64_fast(&mut r.r)
        }
    }
    impl CpIn for i64 {
        fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self {
            read_i64_fast(&mut r.r)
        }
    }
    impl CpIn for char {
        fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self {
            let b = r.r.fill_buf().unwrap()[0] as char;
            r.r.consume(1);
            let s = r.r.fill_buf().unwrap()[0];
            assert!(s == b' ' || s == b'\n');
            r.r.consume(1);
            b
        }
    }

    macro_rules! cpin_tuple {
        ($($t:ident),*) => {
            impl<$($t: CpIn),*> CpIn for ($($t),*) {
                fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self {
                    ($($t::read_from(r)),*)
                }
            }
        };
    }

    macro_rules! cpin_cast {
        ($t_self:ty, $t_read:ty) => {
            impl CpIn for $t_self {
                fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self {
                    <$t_read>::read_from(r) as $t_self
                }
            }
        };
    }
    macro_rules! cpin_parse {
        ($t:ty) => {
            impl CpIn for $t {
                fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self {
                    r.read_word_str().parse().unwrap()
                }
            }
        };
    }
    cpin_cast!(usize, u64);
    cpin_cast!(u32, u64);
    cpin_cast!(u16, u64);
    cpin_cast!(i32, i64);
    cpin_cast!(i16, i64);
    cpin_cast!(i8, i64);

    cpin_parse!(f64);

    cpin_tuple!(T1, T2);
    cpin_tuple!(T1, T2, T3);
    cpin_tuple!(T1, T2, T3, T4);
    cpin_tuple!(T1, T2, T3, T4, T5);

    fn read_u64_fast<R: BufRead>(r: &mut R) -> u64 {
        let mut value = 0;
        loop {
            let mut idx = 0;
            let buf_len;
            {
                let buf = r.fill_buf().unwrap();
                buf_len = buf.len();
                assert!(buf_len != 0);
                while idx < buf_len && b'0' <= buf[idx] && buf[idx] <= b'9' {
                    value = value * 10 + (buf[idx] - b'0') as u64;
                    idx += 1;
                }
            }
            if idx < buf_len {
                r.consume(idx + 1);
                return value;
            }
            r.consume(idx);
        }
    }
    fn read_i64_fast<R: BufRead>(r: &mut R) -> i64 {
        let (consume, sign) = match r.fill_buf().unwrap()[0] {
            b'+' => (true, 1),
            b'-' => (true, -1),
            _ => (false, 1),
        };
        if consume {
            r.consume(1);
        }
        read_u64_fast(r) as i64 * sign
    }
}


use proconio::{fastout, input};

use proconio::marker::Usize1;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [Usize1; n - 1]
    }
    let mut b = vec![0; n];
    for x in a.iter() {
        b[*x] += 1;
    }
    for i in 0..n {
        println!("{}", b[i]);
    }
}


use itertools::Itertools;
fn main() {
    proconio::input! {
        n: usize,
        a: [i64; n-1],
    }
    let mut v = vec![0; n];
    for a in a {
        v[(a - 1) as usize] += 1;
    }
    let ans = v.iter().join("\n");
    println!("{}", ans);
}


use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: i64,
        a: [i64; n-1],
    }
    for _i in 1..a.len() + 2 {
        println!("{:?}", a.iter().filter(|&n| *n == _i as i64).count())
    }
}


use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: i64,
        a: [i64; n-1],
    }
    for _i in 1..a.len() +2 {
        println!("{:?}", a.iter().filter(|&n| *n == _i as i64).count())
    }
}


use proconio::input;
fn main(){
    input!{
        n: usize,
        a: [usize; n - 1]
    }
    let mut ans = vec![0; n + 1];
    for b in a {
        ans[b-1] += 1;
    }
    for i in 1 .. n {
        println!("{}", ans[i])
    }
}


import Foundation
let main: () = {
    let N = nextInt()
    var A = listOfInt(-1)
    var ans = Array(N) { 0 }
    A.forEach { ans[$0] += 1 }
    print(ans.joinToString("\n"))
}()
@inlinable func next() -> String { readLine()! }
@inlinable func nextInt() -> Int { Int(next())! }
@inlinable func nextDouble() -> Double { Double(next())! }
@inlinable func listOfString() -> [String] { next().split(separator: " ").map(String.init) }
@inlinable func listOfInt(_ offset: Int = 0) -> [Int] { listOfString().map { Int($0)! + offset } }
extension Array {
    init(_ size: Int, _ initValue: (() -> Element)) {
        self = [Element]()
        for _ in 0 ..< size {
            let value = initValue()
            self.append(value)
        }
    }
}
extension Array where Element == Int {
    @inlinable func joinToString(_ sepatator: String = " ") -> String { self.map { String($0) }.joined(separator: sepatator) }
}


protocol InitFromString {
    init?(_ str: String)
}

extension Int: InitFromString {}
extension Int8: InitFromString {}
extension Int16: InitFromString {}
extension Int32: InitFromString {}
extension Int64: InitFromString {}
extension String: InitFromString {}

func input<T: InitFromString>() -> [T] {
    readLine()!.split(separator: " ").map(String.init).compactMap(T.init)
}

let n: Int = input()[0]
let a: [Int] = input()

var res = [Int](repeating: 0, count: n)
a.forEach { (i) in
    res[i - 1] += 1
}

print(res.map(String.init).joined(separator: "\n"))


let n = Int(readLine()!)!

let a = readLine()!.split(separator: " ").map {
  Int($0)!
}

var array: [Int] = Array(repeating: 0, count: n)

for member in a {
  array[member-1] += 1
}

print(array.map { String($0) }.joined(separator: "\n"))


import Foundation

func readInts() -> [Int]{
    readLine()!.split(separator: " ").map { Int($0)! }
}

func main(){
    let n = Int(readLine()!)!
    let aryA = readInts()
//    TLE発生
//    for i in 1...n {
//        print(aryA.filter { $0 == i }.count > 0 ? aryA.filter { $0 == i }.count: 0)
//    }
//    修正後
    var counter = [Int](repeating: 0, count: n)
    print(counter)
    for i in aryA {
        counter[i-1] += 1
    }
    for i in 0...aryA.count{
        print(counter[i])
    }
}
main()