#include <bits/stdc++.h>
using namespace std;
int N, curr, p, old;
int P[1100100], dp[1100100], sol[1100100], ch[1100100][3];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N;
  N++;
  for (int I = 2; I <= N; I++) {
    curr = I;
    cin >> P[curr];
    dp[curr] = 1;
    while (curr != 1) {
      p = P[curr];
      old = dp[p];
      ch[p][0] = dp[curr];
      sort(ch[p], ch[p] + 3);
      sol[p] = ch[p][2];
      dp[p] = max(ch[p][2], ch[p][1] + 1);
      if (dp[p] == old) break;
      curr = p;
    }
    cout << sol[1] << " \n"[I == N];
  }
}
