#include <bits/stdc++.h>
using namespace std;
int n;
int f[1000006], fa[1000006], sz[1000006], mx1[1000006], mx2[1000006];
void modify(int);
int main() {
  scanf("%d", &n);
  f[1] = 1;
  for (int i = 2; i <= n + 1; ++i) {
    int x;
    scanf("%d", &x);
    f[i] = 1;
    fa[i] = x;
    modify(i);
    printf("%d ", mx1[1]);
  }
  return 0;
}
void modify(int u) {
  if (u == 1) return;
  if (f[u] > mx1[fa[u]])
    mx2[fa[u]] = mx1[fa[u]], mx1[fa[u]] = f[u];
  else
    mx2[fa[u]] = max(mx2[fa[u]], f[u]);
  int tmp = f[fa[u]];
  f[fa[u]] = max(mx1[fa[u]], mx2[fa[u]] + 1);
  if (f[fa[u]] == tmp) return;
  modify(fa[u]);
  return;
}
