#include <bits/stdc++.h>
using namespace std;
const int N = 314514;
const int M = 19;
int n, mx, s1[N], s2[N], t1, t2, d[N], f[N][21];
void add(int x, int fa) {
  d[x] = d[fa] + 1;
  f[x][0] = fa;
  for (int i = (1); i <= (M); i++) f[x][i] = f[f[x][i - 1]][i - 1];
}
int lca(int x, int y) {
  if (d[x] < d[y]) swap(x, y);
  int rs = d[x] - d[y];
  for (int i = (M); i >= (0); i--)
    if (rs & (1 << i)) x = f[x][i];
  if (x == y) return x;
  for (int i = (M); i >= (0); i--)
    if (f[x][i] != f[y][i])
      x = f[x][i], y = f[y][i];
    else
      continue;
  return f[x][0];
}
int dis(int x, int y) {
  if (!x || !y) return 0;
  return d[x] + d[y] - 2 * d[lca(x, y)];
}
int main() {
  scanf("%d", &n);
  add(1, 0);
  s1[++t1] = 1;
  for (int i = (2); i <= (n + 1); i++) {
    int x;
    scanf("%d", &x);
    add(i, x);
    int d1 = dis(i, s1[1]), d2 = dis(i, s2[1]), d3 = max(d1, d2);
    if (d3 > mx) {
      mx = d3;
      if (d1 == d3) {
        for (int j = (1); j <= (t2); j++)
          if (dis(i, s2[j]) == mx) s1[++t1] = s2[j];
        t2 = 0;
      } else {
        for (int j = (1); j <= (t1); j++)
          if (dis(i, s1[j]) == mx) s2[++t2] = s1[j];
        t1 = 0;
      }
    }
    if (d3 == mx) {
      if (d1 == d3)
        s2[++t2] = i;
      else
        s1[++t1] = i;
    }
    printf("%d\n", t1 + t2);
  }
}
