#include <bits/stdc++.h>
using namespace std;
int n, newd, p[1000001], d[1000001], mx1[1000001], mx2[1000001], u;
void setmax(int id, int v) {
  if (mx1[id] <= v) {
    mx2[id] = mx1[id];
    mx1[id] = v;
  } else {
    if (mx2[id] < v) {
      mx2[id] = v;
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n + 1; i++) {
    mx2[i] = -1;
  }
  for (int i = 2; i <= n + 1; i++) {
    scanf("%d", &p[i]);
    d[i] = 1;
    u = p[i];
    setmax(u, 1);
    while (true) {
      if (u == 1) {
        d[u] = mx1[u];
        break;
      }
      newd = max(mx1[u], mx2[u] + 1);
      if (newd == d[u]) break;
      d[u] = newd;
      setmax(p[u], d[u]);
      u = p[u];
    }
    printf("%d ", d[1]);
  }
  return 0;
}
