#include <bits/stdc++.h>
using namespace std;
const int N = 1001000, M = 1001000;
struct edge {
  int n, v;
} e[M];
int n, f[N], fa[N], hd[N], fl, ans, x1[N], x2[N];
void add(int u, int v) {
  e[++fl] = (edge){hd[u], v};
  hd[u] = fl;
}
int upd(int u, int v) {
  if (f[u] < x2[v]) return 0;
  if (f[u] > x1[v])
    x2[v] = x1[v], x1[v] = f[u];
  else
    x2[v] = f[u];
  int nw = max(x1[u], x2[v] + 1);
  if (nw > f[v]) return f[v] = nw, 1;
  return 0;
}
int main() {
  scanf("%d", &n);
  n++;
  for (int i = 2; i <= n; i++) {
    scanf("%d", &fa[i]), add(fa[i], i);
    f[i] = 1;
    for (int x = i; x && upd(x, fa[x]); x = fa[x])
      ;
    printf("%d ", x1[1]);
  }
}
