#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const double PI = atan(1.0) * 4;
const int inf = ~0u >> 1;
const int Dx[] = {1, 0, -1, 0}, Dy[] = {0, 1, 0, -1};
template <class T>
bool chmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool chmax(T& a, const T& b) {
  return b > a ? a = b, 1 : 0;
}
template <class T>
int sgn(T first) {
  return (first > eps) - (first < -eps);
}
const int maxn = int(1e6) + 9;
int d[maxn], mx1[maxn], mx2[maxn], fa[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (2); i <= (int)(n + 1); i++) {
    scanf("%d", fa + i);
    d[i] = 1;
    for (int j = i; j != 1; j = fa[j]) {
      int f = fa[j];
      if (mx1[f] < d[j])
        mx1[f] = d[j];
      else
        chmax(mx2[f], d[j]);
      if (!chmax(d[f], max(mx1[f], mx2[f] + (f != 1)))) break;
    }
    printf("%d%c", d[1], " \n"[i == n + 1]);
  }
  return 0;
}
