#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
const int mod = 1e9 + 7;
const int INF = 1e9 + 7;
const int mlog = 20;
const int SQ = 400;
int par[maxn], mx1[maxn], mx0[maxn], dp[maxn];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  for (int i = 2; i <= n + 1; i++) {
    cin >> par[i];
    int v = i;
    while (v > 1) {
      int nmx = max(mx0[v], mx1[v] + 1);
      if (nmx <= dp[v]) break;
      int p = par[v];
      if (dp[v] == mx0[p])
        mx0[p] = nmx;
      else if (nmx >= mx0[p])
        mx1[p] = mx0[p], mx0[p] = nmx;
      else if (nmx >= mx1[p])
        mx1[p] = nmx;
      dp[v] = nmx;
      v = p;
    }
    dp[1] = mx0[1];
    cout << dp[1] << ' ';
  }
  return 0;
}
