#include <bits/stdc++.h>
int inp() {
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  int sum = 0;
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum;
}
int f1[1000010];
int f2[1000010];
int f[1000010], fa[1000010];
int main() {
  int n = inp() + 1;
  for (int i = 2; i <= n; i++) {
    fa[i] = inp();
    int cur = i;
    f[cur] = 1;
    f1[i] = f2[i] = 0;
    while (cur != 1) {
      if (f1[fa[cur]] < f[cur]) {
        f2[fa[cur]] = f1[fa[cur]];
        f1[fa[cur]] = f[cur];
      } else if (f2[fa[cur]] < f[cur])
        f2[fa[cur]] = f[cur];
      if (f[fa[cur]] == std::max(f1[fa[cur]], f2[fa[cur]] + 1)) break;
      f[fa[cur]] = std::max(f1[fa[cur]], f2[fa[cur]] + 1);
      cur = fa[cur];
    }
    printf("%d\n", f1[1]);
  }
}
