#include <bits/stdc++.h>
using namespace std;
int n, fa[1000011], f[1000011], max1[1000011], max2[1000011];
inline void R(int &xx) {
  xx = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9')
    xx = xx + xx + (xx << 3) + ch - 48, ch = getchar();
}
inline void R(long long &xx) {
  xx = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9')
    xx = xx + xx + (xx << 3) + ch - 48, ch = getchar();
}
int main() {
  R(n);
  for (int i = 2; i <= n + 1; i++) {
    R(fa[i]);
    f[i] = 1;
    for (int x = i; x - 1; x = fa[x]) {
      if (max1[fa[x]] < f[x])
        max1[fa[x]] = f[x];
      else
        max2[fa[x]] = max(max2[fa[x]], f[x]);
      if (max(max1[fa[x]], max2[fa[x]] + 1) == f[fa[x]]) break;
      f[fa[x]] = max(max1[fa[x]], max2[fa[x]] + 1);
      ;
    }
    printf("%d ", max1[1]);
  }
  puts("");
  return 0;
}
