#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, dp[N], f[N], t[N][2];
int getint() {
  int s = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - 48, ch = getchar();
  return s;
}
void work() {
  n = getint();
  for (int i = 1, p; i <= n; i++) {
    f[i] = getint() - 1, dp[p = i] = 1;
    while (p) {
      if (dp[p] > t[f[p]][0])
        t[f[p]][1] = t[f[p]][0], t[f[p]][0] = dp[p];
      else
        t[f[p]][1] = (t[f[p]][1] > dp[p] ? t[f[p]][1] : dp[p]);
      p = f[p];
      if (dp[p] == (t[p][0] > t[p][1] + 1 ? t[p][0] : t[p][1] + 1))
        break;
      else
        dp[p] = (t[p][0] > t[p][1] + 1 ? t[p][0] : t[p][1] + 1);
    }
    cout << t[0][0] << " ";
  }
}
int main() {
  work();
  return 0;
}
