#include <bits/stdc++.h>
using namespace std;
int n;
int dp[1000005];
int mx1[1000005], mx2[1000005];
int pr[1000005];
void update(int u, int v) {
  int tmp = dp[u];
  if (tmp == mx1[v] + 1)
    mx1[v]++;
  else if (tmp == mx2[v] + 1)
    mx2[v]++;
  else
    return;
  if (max(mx1[v], mx2[v] + 1) > dp[v])
    dp[v] = max(mx1[v], mx2[v] + 1);
  else
    return;
  if (v == 1) return;
  update(v, pr[v]);
}
void process() {
  scanf("%d", &n);
  dp[1] = 0;
  for (int i = 0; i < n; i++) {
    int vx = i + 2;
    scanf("%d", &pr[vx]);
    dp[vx] = 1;
    update(vx, pr[vx]);
    printf("%d ", mx1[1]);
  }
  puts("");
}
int main() {
  process();
  return 0;
}
