#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1 << 20;
int sol[MAXN];
pair<int, int> aaa[MAXN];
int par[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, i, j;
  sol[0] = 0;
  par[0] = -1;
  cin >> n;
  for (i = 1; i <= n; ++i) {
    cin >> par[i];
    --par[i];
    sol[i] = 1;
    j = i;
    while (j) {
      auto& x = aaa[par[j]];
      if (sol[j] > x.first)
        x.first = sol[j];
      else if (sol[j] > x.second)
        x.second = sol[j];
      j = par[j];
      if (max(x.first, 1 + x.second) != sol[j]) {
        ++sol[j];
      } else
        break;
    }
    cout << aaa[0].first << ' ';
  }
}
