#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
vector<int> L, R;
int anc[21][N], dep[N], n;
void add(int fa, int x) {
  dep[x] = dep[fa] + 1;
  anc[0][x] = fa;
  for (int i = 1; i <= 20; i++) anc[i][x] = anc[i - 1][anc[i - 1][x]];
}
int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 20; i >= 0; i--)
    if (dep[x] - (1 << i) >= dep[y]) x = anc[i][x];
  if (x == y) return x;
  for (int i = 20; i >= 0; i--)
    if (anc[i][x] != anc[i][y]) x = anc[i][x], y = anc[i][y];
  return anc[0][x];
}
int len(int x, int y) { return dep[x] + dep[y] - 2 * dep[lca(x, y)]; }
int main() {
  scanf("%d", &n);
  int ans = 0;
  L.push_back(1);
  for (int i = 2; i <= n + 1; i++) {
    int p;
    scanf("%d", &p);
    add(p, i);
    int d1 = L.empty() ? 0 : len(L[0], i);
    int d2 = R.empty() ? 0 : len(R[0], i);
    int d = max(d1, d2);
    if (d > ans) {
      if (d1 == d) {
        for (int j = 0; j < R.size(); j++)
          if (len(R[j], i) == d) L.push_back(R[j]);
        R.clear();
        R.push_back(i);
      } else {
        for (int j = 0; j < L.size(); j++)
          if (len(L[j], i) == d) R.push_back(L[j]);
        L.clear();
        L.push_back(i);
      }
      ans = d;
    } else if (d == ans) {
      if (d1 == d)
        R.push_back(i);
      else
        L.push_back(i);
    }
    printf("%d\n", L.size() + R.size());
  }
  return 0;
}
