#include <bits/stdc++.h>
using namespace std;
int d[2000001];
int son[2000001][2];
int fa[2000001];
int alr[2000001];
int max(int x, int y) { return x > y ? x : y; }
void swap(int &x, int &y) {
  int t = x;
  x = y;
  y = t;
}
void update(int t, int so) {
  while (1) {
    if (t == 0) return;
    if (t == 1) {
      d[1] = max(d[1], d[so]);
      return;
    }
    if (!alr[t]) {
      alr[t] = 1;
      return;
    }
    int temp = d[t];
    if (d[so] > son[t][1]) son[t][1] = d[so];
    if (son[t][1] > son[t][0]) swap(son[t][1], son[t][0]);
    d[t] = max(son[t][0], son[t][1] + 1);
    if (d[t] == temp) return;
    so = t;
    t = fa[t];
  }
}
int main() {
  int n;
  cin >> n;
  alr[1] = 1;
  for (int i = 2; i <= n + 1; i++) {
    scanf("%d", &fa[i]);
    update(fa[i], i);
    printf("%d\n", d[1] + 1);
  }
  return 0;
}
