#include <bits/stdc++.h>
using namespace std;
int m, d, p1, p2, p3;
int L[300010];
int fa[300010][20];
vector<int> s[3];
void Getfather(int i) {
  for (int j = 1; j <= 20; ++j) fa[i][j] = fa[fa[i][j - 1]][j - 1];
}
int LCA(int x, int y) {
  int i, Lg;
  if (L[x] < L[y]) {
    x += y;
    y = x - y;
    x = x - y;
  }
  for (Lg = 1; (1 << Lg) <= L[x]; ++Lg)
    ;
  --Lg;
  for (i = Lg; i >= 0; --i)
    if (L[x] - (1 << i) >= L[y]) x = fa[x][i];
  if (x == y) return x;
  for (i = Lg; i >= 0; --i)
    if (fa[x][i] && fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  return fa[x][0];
}
int DIS(int u, int v) {
  int fat = LCA(u, v);
  return L[u] + L[v] - 2 * L[fat];
}
void Add(int u, int fat) {
  L[u] = L[fat] + 1;
  fa[u][0] = fat;
  Getfather(u);
  int vis[3] = {}, res;
  vis[p1] = vis[p2] = true;
  for (p3 = 0; vis[p3]; ++p3)
    ;
  s[p3].clear();
  if (s[p1].size() > 0 && (res = DIS(s[p1][0], u)) > d) {
    d = res;
    s[p3].push_back(u);
    for (auto &v : s[p2]) {
      if (DIS(v, u) == d) s[p1].push_back(v);
    }
    p2 = p3;
    return;
  }
  if (s[p2].size() > 0 && (res = DIS(s[p2][0], u)) > d) {
    d = res;
    s[p3].push_back(u);
    for (auto &v : s[p1]) {
      if (DIS(v, u) == d) s[p2].push_back(v);
    }
    p1 = p3;
    return;
  }
  if (s[p1].size() > 0 && (res = DIS(s[p1][0], u)) == d) {
    s[p2].push_back(u);
    return;
  }
  if (s[p2].size() > 0 && (res = DIS(s[p2][0], u)) == d) {
    s[p1].push_back(u);
    return;
  }
}
void Work() {
  int i, fat;
  p1 = 0;
  p2 = 1;
  s[0].push_back(1);
  for (scanf("%d", &m), i = 2; m; --m, ++i) {
    scanf("%d", &fat);
    Add(i, fat);
    printf("%d\n", s[p1].size() + s[p2].size());
  }
}
int main() {
  Work();
  return 0;
}
