#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 100;
set<int> t;
set<int>::iterator it;
vector<int> side[maxn];
int dep[maxn], size[maxn], f[maxn][21], dfn[maxn], dfn_cnt, idx[maxn];
int LCA(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (int i = 20; i >= 0; i--)
    if (dep[f[u][i]] >= dep[v]) u = f[u][i];
  if (u == v) return u;
  for (int i = 20; i >= 0; i--)
    if (f[u][i] != f[v][i]) u = f[u][i], v = f[v][i];
  return f[u][0];
}
int dis(int u, int v) {
  int lca = LCA(u, v);
  return (dep[u] - dep[lca]) + (dep[v] - dep[lca]);
}
void dfs(int u, int fa) {
  dep[u] = dep[fa] + 1;
  f[u][0] = fa;
  size[u] = 1;
  dfn[u] = ++dfn_cnt;
  idx[dfn_cnt] = u;
  for (int i = (1), iend = (20); i <= iend; i++)
    f[u][i] = f[f[u][i - 1]][i - 1];
  for (int i = 0; i < side[u].size(); i++) {
    int v = side[u][i];
    if (v == fa) continue;
    dfs(v, u);
    size[u] += size[v];
  }
}
int st = 1, ed = 1, len = 0;
int ck(int u, int v) {
  if (dis(u, v) < len && u != v) return 1;
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  n++;
  for (int i = (2), iend = (n); i <= iend; i++) {
    int v;
    cin >> v;
    side[v].push_back(i);
  }
  dfs(1, 0);
  t.insert(1);
  for (int i = (2), iend = (n); i <= iend; i++) {
    if (i == 8) {
      int gg = 1;
    }
    int ndis = max(dis(st, i), dis(i, ed));
    if (ndis > len) {
      if (dis(st, i) > len)
        ed = i;
      else
        st = i;
      len = ndis;
      t.insert(dfn[i]);
      it = t.upper_bound(dfn[i]);
      while (it != t.end()) {
        if (ck(i, idx[*it])) {
          t.erase(it);
          it = t.upper_bound(dfn[i]);
        } else
          break;
      }
      if (it == t.end()) {
        it = t.begin();
        while (it != t.end()) {
          if (ck(i, idx[*it])) {
            t.erase(it);
            it = t.begin();
          } else
            break;
        }
      }
      it = t.lower_bound(dfn[i]);
      if (it != t.begin()) --it;
      do {
        if (it == t.end()) break;
        if (ck(i, idx[*it])) {
          t.erase(it);
          it = t.lower_bound(dfn[i]);
          if (it == t.begin()) break;
          it--;
        } else
          break;
      } while (1);
      if (it == t.begin()) it = --t.end();
      do {
        if (it == t.end()) break;
        if (ck(i, idx[*it])) {
          t.erase(it);
          it = --t.end();
        } else
          break;
      } while (1);
      printf("%d\n", t.size());
    } else {
      if (ndis == len) t.insert(dfn[i]);
      printf("%d\n", t.size());
    }
  }
  return 0;
}
