#include <bits/stdc++.h>
using namespace std;
int read() {
  int s = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 3) + (s << 1) + ch - '0', ch = getchar();
  return f * s;
}
struct edge {
  int to, lt;
} e[300010];
int n, in[300010], cnt, f[300010][20], dep[300010], dfn[300010], sz[300010],
    idfn[300010], tms;
void add(int x, int y) {
  e[++cnt].to = y;
  e[cnt].lt = in[x];
  in[x] = cnt;
}
void dfs(int x) {
  sz[x] = 1;
  for (int i = 1; i < 20; i++) f[x][i] = f[f[x][i - 1]][i - 1];
  dfn[x] = ++tms;
  idfn[tms] = x;
  for (int i = in[x]; i; i = e[i].lt) {
    int y = e[i].to;
    dep[y] = dep[x] + 1;
    dfs(y);
    sz[x] += sz[y];
  }
}
int jump(int x, int l) {
  for (int i = 0; i < 20; i++)
    if (l >> i & 1) x = f[x][i];
  return x;
}
int LCA(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  x = jump(x, dep[x] - dep[y]);
  if (x == y) return x;
  for (int i = 19; ~i; i--)
    if (f[x][i] ^ f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
int dis(int x, int y) { return dep[x] + dep[y] - 2 * dep[LCA(x, y)]; }
set<int> st;
int ra, rb, d;
int get(int x, int y, int d) {
  return dep[x] >= d ? jump(x, d) : jump(y, dis(x, y) - d);
}
bool tin(int x, int y) { return dfn[x] >= dfn[y] && dfn[x] < dfn[y] + sz[y]; }
void ers(int x, int d) {
  if (d)
    st.erase(st.lower_bound(dfn[x]), st.lower_bound(dfn[x] + sz[x]));
  else
    st.erase(st.begin(), st.lower_bound(dfn[x])),
        st.erase(st.lower_bound(dfn[x] + sz[x]), st.end());
}
void sv(int x, int sx) {
  if (tin(x, sx))
    ers(x, 0);
  else
    ers(sx, 1);
}
void del(int x, int y, int d) {
  int m, mx;
  if (d & 1) {
    m = get(y, x, d >> 1), mx = get(x, y, d >> 1);
    sv(m, mx);
  } else {
    m = get(x, y, d >> 1);
    mx = get(y, x, (d >> 1) - 1);
    sv(mx, m);
  }
}
int main() {
  n = read() + 1;
  for (int i = 2; i <= n; i++) add(f[i][0] = read(), i);
  dfs(1);
  ra = 1, rb = 2, d = 1;
  st.insert(dfn[1]);
  st.insert(dfn[2]);
  printf("2\n");
  for (int i = 3; i <= n; i++) {
    int da = dis(i, ra), db = dis(i, rb), w;
    if (da > d || db > d) {
      if (da > d)
        rb = i, w = ra, d = da;
      else
        ra = i, w = rb, d = db;
      del(i, w, d);
      st.insert(dfn[i]);
    } else if (da == d || db == d)
      st.insert(dfn[i]);
    printf("%d\n", st.size());
  }
  return 0;
}
