#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n, dfn[N], rk[N], idx, d[N], fa[19][N];
vector<int> G[N];
void dfs(int u) {
  dfn[u] = ++idx, rk[idx] = u;
  for (int i = (1); i <= (18); i++) fa[i][u] = fa[i - 1][fa[i - 1][u]];
  for (int v : G[u]) d[v] = d[u] + 1, fa[0][v] = u, dfs(v);
}
int dis(int u, int v) {
  u = rk[u], v = rk[v];
  if (d[u] < d[v]) swap(u, v);
  int re = d[u] - d[v];
  for (int i = (18); i >= (0); i--)
    if (d[u] - (1 << i) >= d[v]) u = fa[i][u];
  if (u == v) return re;
  for (int i = (18); i >= (0); i--)
    if (fa[i][u] ^ fa[i][v]) u = fa[i][u], v = fa[i][v], re += 2 << i;
  return re + 2;
}
int main() {
  cin >> n, n++;
  int f;
  for (int i = (2); i <= (n); i++) scanf("%d", &f), G[f].push_back(i);
  dfs(1);
  int u = 1, v = 1, D = 0;
  set<int> s = {1};
  for (int k = (2); k <= (n); k++) {
    int i = dfn[k];
    if (dis(i, u) > D) v = i, D++;
    if (dis(i, v) > D) u = i, D++;
    if (dis(i, u) == D || dis(i, v) == D) s.insert(i);
    auto chk = [&](int x) {
      if (dis(x, u) < D && dis(x, v) < D) return s.erase(x), 1;
      return 0;
    };
    while (chk(i < *s.rbegin() ? *s.upper_bound(i) : *s.begin()))
      ;
    while (chk(i > *s.begin() ? *--s.lower_bound(i) : *s.rbegin()))
      ;
    printf("%llu\n", s.size());
  }
  return 0;
}
