#include <bits/stdc++.h>
using namespace std;
const int SIZ = 3e5 + 2007;
int fa[SIZ][20];
int dep[SIZ];
int dist(int u, int v) {
  int ret = 0;
  if (dep[u] < dep[v]) swap(u, v);
  for (int i = 19; i >= 0; i--)
    if (dep[fa[u][i]] >= dep[v]) u = fa[u][i], ret += (1 << i);
  if (u == v) return ret;
  for (int i = 19; i >= 0; i--)
    if (fa[u][i] != fa[v][i]) u = fa[u][i], v = fa[v][i], ret += (1 << i) << 1;
  return ret + 2;
}
int N;
set<int> s1, s2;
int main() {
  scanf("%d", &N);
  dep[1] = 1;
  s1.insert(1);
  int mx = 1;
  for (int v = 2, u; v <= N + 1; v++) {
    scanf("%d", &u);
    fa[v][0] = u;
    dep[v] = dep[u] + 1;
    for (int i = 1; i < 20; i++) fa[v][i] = fa[fa[v][i - 1]][i - 1];
    int dist1 = s1.empty() ? 0 : dist(v, *s1.begin());
    int dist2 = s2.empty() ? 0 : dist(v, *s2.begin());
    if (max(dist1, dist2) > mx) {
      mx = max(dist1, dist2);
      if (dist1 == mx) {
        for (int u : s2)
          if (dist(u, v) == mx) s1.insert(u);
        s2.clear();
        s2.insert(v);
      } else {
        for (int u : s1)
          if (dist(u, v) == mx) s2.insert(u);
        s1.clear();
        s1.insert(v);
      }
    } else if (max(dist1, dist2) == mx) {
      if (dist1 >= dist2)
        s2.insert(v);
      else
        s1.insert(v);
    }
    printf("%d\n", int(s1.size() + s2.size()));
  }
}
