#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int w = 1, s = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return w * s;
}
vector<int> vec[2];
int fa[400010][21], dep[400100], n, curd;
inline int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (register int i = 19; i >= 0; --i)
    if (dep[fa[u][i]] >= dep[v]) u = fa[u][i];
  if (u == v) return u;
  for (register int i = 19; i >= 0; --i)
    if (fa[u][i] != fa[v][i]) u = fa[u][i], v = fa[v][i];
  return fa[u][0];
}
inline int getdis(int u, int v) { return dep[u] + dep[v] - 2 * dep[lca(u, v)]; }
inline void Insert(int u) {
  if (vec[0].size() && getdis(u, vec[0][0]) > curd) {
    curd++;
    int sz = vec[1].size();
    for (register int j = 0; j < sz; ++j)
      if (getdis(vec[1][j], u) == curd) vec[0].push_back(vec[1][j]);
    vec[1].clear();
    vec[1].push_back(u);
  } else if (vec[1].size() && getdis(u, vec[1][0]) > curd) {
    curd++;
    int sz = vec[0].size();
    for (register int j = 0; j < sz; ++j)
      if (getdis(vec[0][j], u) == curd) vec[1].push_back(vec[0][j]);
    vec[0].clear();
    vec[0].push_back(u);
  } else if (vec[0].size() && (getdis(vec[0][0], u) == curd))
    vec[1].push_back(u);
  else if (vec[1].size() && (getdis(vec[1][0], u) == curd))
    vec[0].push_back(u);
}
int main() {
  n = read();
  vec[0].push_back(1);
  dep[1] = 1;
  for (register int i = 2; i <= n + 1; ++i) {
    fa[i][0] = read();
    dep[i] = dep[fa[i][0]] + 1;
    for (register int j = 1; j <= 19; ++j) fa[i][j] = fa[fa[i][j - 1]][j - 1];
    Insert(i);
    cout << vec[0].size() + vec[1].size() << "\n";
  }
  return 0;
}
