#include <bits/stdc++.h>
using namespace std;
inline int Get() {
  int res = 0, q = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') q = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') res = res * 10 + ch - '0', ch = getchar();
  return res * q;
}
const double eps = 1e-12, pi = M_PI;
const int oo = (int)2e9, mod = (int)1e9 + 7;
const long long INF = (long long)1e17;
const int N = (int)1e6;
typedef int arr[N + 10];
int i, j, k, p, n, m;
arr f, ms, mf, fat;
bool Update(int x, int fa) {
  if (f[x] <= ms[fa]) return 0;
  if (f[x] > mf[fa])
    ms[fa] = mf[fa], mf[fa] = f[x];
  else
    ms[fa] = f[x];
  if (f[fa] == ms[fa] + 1) return 0;
  return f[fa] = ms[fa] + 1, 1;
}
int main() {
  scanf(
      "%d"
      "\n",
      &n),
      ++n;
  f[1] = 1, ms[1] = 0;
  for (int i = (2), end = (n); i <= end; ++i) {
    scanf(
        "%d"
        "\n",
        &p),
        fat[i] = p, f[i] = 1;
    int x = i;
    for (; fat[x] && Update(x, fat[x]); x = fat[x])
      ;
    printf(
        "%d"
        " ",
        mf[1]);
  }
  return 0;
}
