#include <bits/stdc++.h>
using namespace std;
const int maxm = 300005;
int fa[maxm][20];
int dep[maxm];
set<int> s1, s2;
int getdist(int u, int v) {
  int res = 0;
  if (dep[u] < dep[v]) swap(u, v);
  for (int i = 19; i >= 0; i--) {
    if (dep[u] - dep[v] >= (1 << i)) {
      u = fa[u][i];
      res += (1 << i);
    }
  }
  if (u == v) return res;
  for (int i = 19; i >= 0; i--) {
    if (fa[u][i] != fa[v][i]) {
      u = fa[u][i];
      v = fa[v][i];
      res += (1 << (i + 1));
    }
  }
  return res + 2;
}
int main() {
  int m;
  cin >> m;
  int temp;
  s1.insert(1);
  int mx = 1;
  for (int i = 2; i <= m + 1; i++) {
    scanf("%d", &temp);
    fa[i][0] = temp;
    dep[i] = dep[temp] + 1;
    for (int j = 1; j < 20; j++) fa[i][j] = fa[fa[i][j - 1]][j - 1];
    int dist1 = s1.empty() ? 0 : getdist(i, *s1.begin());
    int dist2 = s2.empty() ? 0 : getdist(i, *s2.begin());
    if (max(dist1, dist2) > mx) {
      mx = max(dist1, dist2);
      if (dist1 == mx) {
        for (int j : s2) {
          if (getdist(i, j) == mx) s1.insert(j);
        }
        s2.clear();
        s2.insert(i);
      } else {
        for (int j : s1) {
          if (getdist(i, j) == mx) s2.insert(j);
        }
        s1.clear();
        s1.insert(i);
      }
    } else if (max(dist1, dist2) == mx) {
      if (dist1 == mx)
        s2.insert(i);
      else
        s1.insert(i);
    }
    cout << s1.size() + s2.size() << endl;
  }
  return 0;
}
