#include <bits/stdc++.h>
using namespace std;
set<int> s1, s2;
int fa[300007][20], deep[300007] = {0, 1}, mx = 1, n;
int lca(int a, int b) {
  int res = 0;
  if (deep[a] < deep[b]) swap(a, b);
  for (int i = 18; ~i; --i)
    if (deep[a] - (1 << i) >= deep[b]) a = fa[a][i], res += 1 << i;
  if (a == b) return res;
  for (int i = 18; ~i; --i)
    if (fa[a][i] != fa[b][i]) res += 1 << (i + 1), a = fa[a][i], b = fa[b][i];
  return res + 2;
}
int main() {
  scanf("%d", &n);
  s1.insert(1);
  for (int v = 2, u; v <= n + 1; ++v) {
    scanf("%d", &u);
    fa[v][0] = u;
    deep[v] = deep[u] + 1;
    for (int i = 1; (1 << i) < deep[v]; i++) fa[v][i] = fa[fa[v][i - 1]][i - 1];
    int dis1 = s1.empty() ? 0 : lca(v, *s1.begin()),
        dis2 = s2.empty() ? 0 : lca(v, *s2.begin());
    if (max(dis1, dis2) > mx) {
      mx = max(dis1, dis2);
      if (dis1 == mx) {
        for (set<int>::iterator it = s2.begin(); it != s2.end(); ++it)
          if (lca(*it, v) == mx) s1.insert(*it);
        s2.clear();
        s2.insert(v);
      } else {
        for (set<int>::iterator it = s1.begin(); it != s1.end(); ++it)
          if (lca(*it, v) == mx) s2.insert(*it);
        s1.clear();
        s1.insert(v);
      }
    } else if (max(dis1, dis2) == mx)
      if (dis1 >= dis2)
        s2.insert(v);
      else
        s1.insert(v);
    int ans = s1.size() + s2.size();
    printf("%d\n", ans);
  }
  return 0;
}
