#include <bits/stdc++.h>
using namespace std;
void _fill_int(int* p, int val, int rep) {
  int i;
  for (i = 0; i < rep; i++) p[i] = val;
}
int N;
int P[1000002];
int dp[1000002];
int col[2][1000002];
void solve() {
  int f, i, j, k, l, x, y;
  cin >> N;
  for (i = 1; i <= N; i++) {
    cin >> P[i];
    P[i]--;
    int cur = i;
    dp[cur] = 1;
    while (cur > 0) {
      int pa = P[cur];
      if (dp[cur] > col[0][pa])
        col[1][pa] = col[0][pa], col[0][pa] = dp[cur];
      else
        col[1][pa] = max(col[1][pa], dp[cur]);
      if (max(col[0][pa], col[1][pa] + 1) <= dp[pa]) break;
      dp[pa] = max(col[0][pa], col[1][pa] + 1);
      cur = pa;
    }
    (void)printf("%d ", col[0][0]);
  }
  (void)printf("\n");
}
int main(int argc, char** argv) {
  string s;
  if (argc == 1) ios::sync_with_stdio(false);
  for (int i = 1; i < argc; i++) s += argv[i], s += '\n';
  for (int i = s.size() - 1; i >= 0; i--) ungetc(s[i], stdin);
  solve();
  return 0;
}
