#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 7, LOGN = 20;
int dp[N][LOGN], head[N], cnt, level[N], n;
inline int read() {
  int x = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
struct EDGE {
  int to, next;
} e[2 * N];
void add(int u, int v) {
  ++cnt;
  e[cnt].to = u, e[cnt].next = head[v];
  head[v] = cnt;
}
void addedge(int u, int v) {
  add(u, v);
  add(v, u);
}
void dfs(int x) {
  for (int i = head[x]; i; i = e[i].next)
    if (e[i].to != dp[x][0]) {
      level[e[i].to] = level[x] + 1;
      dp[e[i].to][0] = x;
      dfs(e[i].to);
    }
}
void inti() {
  level[1] = 0;
  dp[1][0] = 0;
  dfs(1);
  for (int i = 1; i < LOGN; i++)
    for (int j = 1; j <= n + 1; j++) dp[j][i] = dp[dp[j][i - 1]][i - 1];
}
int lca(int a, int b) {
  if (level[a] > level[b]) swap(a, b);
  int d = level[b] - level[a];
  for (int i = 0; i < LOGN; i++)
    if (d & (1 << i)) b = dp[b][i];
  if (a == b) return a;
  for (int i = LOGN - 1; i >= 0; i--)
    if (dp[a][i] != dp[b][i]) a = dp[a][i], b = dp[b][i];
  return dp[a][0];
}
int dist(int a, int b) { return level[a] + level[b] - 2 * level[lca(a, b)]; }
int main() {
  n = read();
  for (int i = 1; i <= n; i++) addedge(i + 1, read());
  inti();
  int mx = 1;
  set<int> s1{1}, s2;
  for (int i = 2; i <= n + 1; i++) {
    int d1 = s1.empty() ? 0 : dist(i, *s1.begin()),
        d2 = s2.empty() ? 0 : dist(i, *s2.begin());
    if (max(d1, d2) > mx) {
      mx = max(d1, d2);
      if (d1 == mx) {
        for (auto u : s2)
          if (dist(u, i) == mx) s1.insert(u);
        s2.clear();
        s2.insert(i);
      } else {
        for (auto u : s1)
          if (dist(u, i) == mx) s2.insert(u);
        s1.clear();
        s1.insert(i);
      }
    } else if (max(d1, d2) == mx) {
      if (d1 >= d2)
        s2.insert(i);
      else
        s1.insert(i);
    }
    printf("%d\n", (int)(s1.size() + s2.size()));
  }
}
