#include <bits/stdc++.h>
using namespace std;
int N, F[1000005], T[1000005], A[1000005], B[1000005];
int IN() {
  int x = 0, ch;
  for (; (ch = getchar()) < '0' || ch > '9';)
    ;
  for (; ch >= '0' && ch <= '9'; (ch = getchar())) (x *= 10) += ch - '0';
  return x;
}
int main() {
  N = IN() + 1;
  for (int i = 2; i <= N; i++) {
    T[i] = 1;
    F[i] = IN();
    for (int x = F[i], y = i; x; x = F[y = x]) {
      if (T[y] > A[x])
        A[x] = T[y];
      else
        B[x] = ((B[x]) > (T[y]) ? (B[x]) : (T[y]));
      int t = ((A[x]) > (B[x] + 1) ? (A[x]) : (B[x] + 1));
      if (t == T[x]) break;
      T[x] = t;
    }
    printf("%d ", A[1]);
  }
}
