#include <bits/stdc++.h>
using namespace std;
const int N = 1000100;
int n, p[N];
int mx1[N], mx2[N], ans[N];
int main() {
  scanf("%d", &n);
  for (int v, best, i = 2; i <= n + 1; i++) {
    scanf("%d", p + i);
    v = i;
    while (v != 0) {
      best = max(mx1[v], mx2[v] + 1);
      if (best <= ans[v]) break;
      ans[v] = best;
      if (mx2[p[v]] < best) mx2[p[v]] = best;
      if (mx1[p[v]] < mx2[p[v]]) swap(mx1[p[v]], mx2[p[v]]);
      v = p[v];
    }
    printf("%d ", max(mx1[1], mx2[1]));
  }
  return 0;
}
