#include <bits/stdc++.h>
using namespace std;
int M;
int P[21][300005], D[300005];
set<int> L;
int X, Y, dia;
int dist(int a, int b) {
  int ret = 0, i, aa = a, bb = b;
  if (D[aa] > D[bb]) swap(aa, bb);
  for (i = 19; i >= 0; i--)
    if (D[bb] - D[aa] >= 1 << i) bb = P[i][bb];
  for (i = 19; i >= 0; i--)
    if (P[i][aa] != P[i][bb]) aa = P[i][aa], bb = P[i][bb];
  return D[a] + D[b] - 2 * D[(aa == bb) ? aa : P[0][aa]];
}
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> M;
  for (i = 0; i < (M); i++) {
    cin >> P[0][i + 1];
    P[0][i + 1]--;
    D[i + 1] = D[P[0][i + 1]] + 1;
  }
  M++;
  for (i = 0; i < (19); i++)
    for (x = 0; x < (M); x++) P[i + 1][x] = P[i][P[i][x]];
  cout << 2 << endl;
  X = 0, Y = 1;
  dia = 1;
  L.insert(0);
  L.insert(1);
  int ret = 2;
  for (i = 2; i < M; i++) {
    L.erase(P[0][i]);
    int dx = dist(X, i);
    int dy = dist(Y, i);
    if (dx <= dia && dy <= dia) {
      if (dx == dia || dy == dia) L.insert(i);
    } else {
      if (dy > dia) swap(X, Y), swap(dx, dy);
      dia = dx;
      Y = i;
      set<int> L2 = L;
      L.clear();
      for (auto& r : L2)
        if (dist(r, Y) == dia) L.insert(r);
      L.insert(X);
      L.insert(Y);
    }
    cout << L.size() << endl;
  }
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  cout.tie(0);
  solve();
  return 0;
}
