#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 1000 + 2;
int mx[MAXN + 10][2];
int val[MAXN + 10];
int par[MAXN + 10];
int n;
void set_val(int v) {
  int newVal = max(mx[v][0], mx[v][1] + 1);
  if (v == 0 || newVal == val[v]) return;
  val[v] = newVal;
  if (mx[par[v]][1] < val[v]) {
    mx[par[v]][1] = val[v];
    if (mx[par[v]][0] < val[v]) swap(mx[par[v]][0], mx[par[v]][1]);
    set_val(par[v]);
  }
}
int main() {
  cin >> n;
  n++;
  for (int i = 1; i < n; i++) {
    int p;
    scanf("%d", &p);
    p--;
    par[i] = p;
    set_val(i);
    printf("%d ", mx[0][0]);
  }
  printf("\n");
  return 0;
}
