#include <bits/stdc++.h>
using namespace std;
const long long LLINF = 1e18;
const int INF = 1e9;
const double EPS = 1e-7;
inline const int &INT() {
  static int x;
  scanf("%d", &x);
  return x;
}
inline const long long &LONG() {
  static long long x;
  scanf("%lld", &x);
  return x;
}
template <class T>
inline void MIN(T &a, const T &b) {
  if (b < a) a = b;
}
template <class T>
inline void MAX(T &a, const T &b) {
  if (b > a) a = b;
}
const int NN = 1e6 + 5;
int F[NN], N, par[NN];
int a[NN], b[NN], child[NN];
int main() {
  N = INT();
  F[1] = 1;
  for (int i = (2); i <= (N + 1); ++i) {
    par[i] = INT();
    ++child[par[i]];
    F[i] = 1;
    int t = i;
    while (1) {
      if (t == 1) break;
      int p = par[t];
      if (a[p] != t && b[p] != t) {
        if (F[t] > F[b[p]])
          b[p] = t;
        else if (F[t] > F[a[p]])
          a[p] = t;
      } else {
        if (F[a[p]] > F[b[p]]) swap(a[p], b[p]);
      }
      int ff;
      ff = max(F[a[p]] + 1, F[b[p]]);
      if (ff == F[p]) break;
      F[p] = ff;
      t = p;
    }
    cout << F[b[1]] << " ";
  }
  cout << endl;
  return 0;
}
