#include <bits/stdc++.h>
using namespace std;
int main() {
  static int n, u, p[1000005], f[1000005], g[1000005], h[1000005];
  scanf("%d", &n), ++n;
  for (register int i = 2; i <= n; ++i) {
    scanf("%d", p + i), u = i;
    while ((u ^ 1) && f[u] < max(g[u], h[u] + 1)) {
      f[u] = max(g[u], h[u] + 1);
      if (g[p[u]] <= f[u])
        h[p[u]] = g[p[u]], g[p[u]] = f[u];
      else if (h[p[u]] <= f[u])
        h[p[u]] = f[u];
      u = p[u];
    }
    printf("%d ", g[1]);
  }
  return 0;
}
