#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 100;
int parent[25][N];
int dep[N];
int lca(int u, int v) {
  if (dep[u] > dep[v]) swap(u, v);
  for (int k = 0; k <= 20; k++) {
    if ((dep[v] - dep[u]) >> k & 1) {
      v = parent[k][v];
    }
  }
  if (u == v) return u;
  for (int k = 20; k >= 0; k--) {
    if (parent[k][u] != parent[k][v]) {
      u = parent[k][u];
      v = parent[k][v];
    }
  }
  return parent[0][u];
}
void update(int v, int f) {
  parent[0][v] = f;
  for (int i = 0; i <= 20; i++) {
    if (parent[i][v] < 0) parent[i][v] = -1;
    parent[i + 1][v] = parent[i][parent[i][v]];
  }
}
set<int> s1, s2;
vector<int> v;
int dis(int u, int v) {
  int f = lca(u, v);
  return dep[v] + dep[u] - 2 * dep[f] + 1;
}
int main() {
  int n;
  cin >> n;
  update(1, -1);
  dep[1] = 1;
  bool tmp = true;
  s1.insert(1);
  int mx = 1;
  for (int i = 1; i <= n; i++) {
    int now;
    scanf("%d", &now);
    update(i + 1, now);
    dep[i + 1] = dep[now] + 1;
    int d1 = s1.empty() ? 0 : dis(i + 1, *s1.begin());
    int d2 = s2.empty() ? 0 : dis(i + 1, *s2.begin());
    if (max(d1, d2) > mx) {
      mx = max(d1, d2);
      if (mx == d1) {
        for (set<int>::iterator iter = s2.begin(); iter != s2.end(); iter++) {
          if (dis(*iter, i + 1) == mx) s1.insert(*iter);
        }
        s2.clear();
        s2.insert(i + 1);
      } else {
        for (set<int>::iterator iter = s1.begin(); iter != s1.end(); iter++) {
          if (dis(*iter, i + 1) == mx) s2.insert(*iter);
        }
        s1.clear();
        s1.insert(i + 1);
      }
    } else if (max(d1, d2) == mx) {
      if (d1 == mx) {
        s2.insert(i + 1);
      } else
        s1.insert(i + 1);
    }
    printf("%d\n", s1.size() + s2.size());
  }
  return 0;
}
