#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
struct edge {
  int nx, t;
} e[600000 * 2 + 5];
int h[600000 + 5], en, l[600000 + 5], r[600000 + 5], cnt, d[600000 + 5],
    fa[20][600000 + 5];
inline void ins(int x, int y) {
  e[++en] = (edge){h[x], y};
  h[x] = en;
  e[++en] = (edge){h[y], x};
  h[y] = en;
}
void dfs(int x) {
  l[x] = ++cnt;
  for (int i = h[x]; i; i = e[i].nx)
    if (e[i].t != fa[0][x])
      fa[0][e[i].t] = x, d[e[i].t] = d[x] + 1, dfs(e[i].t);
  r[x] = cnt;
}
int dis(int x, int y) {
  if (d[x] < d[y]) swap(x, y);
  int res = d[x] - d[y], i, dx = d[x] - d[y];
  for (i = 0; dx; ++i, dx >>= 1)
    if (dx & 1) x = fa[i][x];
  if (x == y) return res;
  for (i = 20; i--;)
    if (fa[i][x] != fa[i][y]) x = fa[i][x], y = fa[i][y], res += 1 << i + 1;
  return res + 2;
}
struct node {
  int l, r, s, mk;
} t[600000 * 4 + 5];
inline void up(int k) { t[k].s = t[(k << 1)].s + t[(k << 1 | 1)].s; }
inline void mark(int k) {
  t[k].s = 0;
  t[k].mk = 1;
}
inline void down(int k) {
  if (t[k].mk) mark((k << 1)), mark((k << 1 | 1)), t[k].mk = 0;
}
void build(int k, int l, int r) {
  if ((t[k].l = l) == (t[k].r = r)) return;
  int mid = l + r >> 1;
  build((k << 1), l, mid);
  build((k << 1 | 1), mid + 1, r);
}
void add(int k, int x) {
  if (++t[k].s, t[k].l == t[k].r) return;
  down(k);
  add(x > (t[k].l + t[k].r >> 1) ? (k << 1 | 1) : (k << 1), x);
}
void mark(int k, int l, int r) {
  if (t[k].l == l && t[k].r == r) {
    mark(k);
    return;
  }
  int mid = t[k].l + t[k].r >> 1;
  down(k);
  if (r <= mid)
    mark((k << 1), l, r);
  else if (l > mid)
    mark((k << 1 | 1), l, r);
  else
    mark((k << 1), l, mid), mark((k << 1 | 1), mid + 1, r);
  up(k);
}
int main() {
  int n = read() + 1, i, j, k, x, s = 1, ds = 0;
  for (i = 2; i <= n; ++i) ins(read(), n + i - 1), ins(n + i - 1, i);
  dfs(1);
  for (i = 1; i < 20; ++i)
    for (j = 1; j < n * 2; ++j) fa[i][j] = fa[i - 1][fa[i - 1][j]];
  build(1, 1, n * 2 - 1);
  add(1, 1);
  for (i = 2; i <= n; ++i) {
    if ((j = dis(i, s)) > ds) {
      if (j == d[i] - d[s]) {
        for (x = i, k = 20; k--;)
          if (d[fa[k][x]] > d[s]) x = fa[k][x];
        s = x;
        mark(1, l[s], r[s]);
      } else {
        if (l[s] > 1) mark(1, 1, l[s] - 1);
        if (r[s] < n * 2 - 1) mark(1, r[s] + 1, n * 2 - 1);
        s = fa[0][s];
      }
      j = ds = dis(i, s);
    }
    if (j == ds) add(1, l[i]);
    printf("%d\n", t[1].s);
  }
}
