#include <bits/stdc++.h>
using namespace std;
int n, i, j, la, hh, fa[1000010], mx[1000010], id[1000010], cnt[1000010], flag;
int main() {
  scanf("%d", &n);
  n++;
  for (i = 2; i <= n; i++) {
    scanf("%d", &fa[i]);
    id[i] = 1;
    la = -1;
    for (j = i; j != 1; j = fa[j]) {
      flag = 0;
      hh = mx[fa[j]] + id[fa[j]];
      if (mx[j] + id[j] > mx[fa[j]]) {
        mx[fa[j]] = mx[j] + id[j];
        cnt[fa[j]] = 1;
        flag = 1;
        id[fa[j]] = 0;
      } else if (mx[j] + id[j] == mx[fa[j]] && la < mx[fa[j]]) {
        cnt[fa[j]]++;
        if (cnt[fa[j]] == 2) flag = 1, id[fa[j]] = 1;
      }
      la = hh;
      if (!flag) break;
    }
    printf("%d ", mx[1]);
  }
}
