#include <bits/stdc++.h>
using namespace std;
int dp[1000005][2];
int sdp[1000005][2];
int fa[1000005];
int main() {
  int n;
  scanf("%d", &n);
  memset(dp, 0, sizeof(dp));
  memset(sdp, -1, sizeof(sdp));
  memset(fa, 0, sizeof(fa));
  fa[1] = 0;
  dp[1][0] = dp[1][1] = 0;
  for (int i = 1; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    fa[i + 1] = x;
    dp[i + 1][0] = 0, dp[i + 1][1] = 0;
    int son = i + 1, f = x;
    while (f) {
      int max1 = -1, max2 = -1;
      int val = max(dp[son][0], dp[son][1] + 1);
      if (val > dp[f][0]) {
        if (sdp[f][0] == son) {
          dp[f][0] = val;
        } else {
          sdp[f][1] = sdp[f][0];
          sdp[f][0] = son;
          dp[f][1] = dp[f][0];
          dp[f][0] = val;
        }
      } else if (val > dp[f][1] && son != sdp[f][0]) {
        dp[f][1] = val;
        sdp[f][1] = son;
      } else {
        break;
      }
      son = f;
      f = fa[son];
    }
    printf("%d%c", dp[1][0], i == n ? '\n' : ' ');
  }
  return 0;
}
