#include <bits/stdc++.h>
using namespace std;
long long p[1000010], dp[1000010];
vector<long long> vec[1000010];
void add(long long n, long long val) {
  vec[n].push_back(val);
  sort(vec[n].begin(), vec[n].end(), greater<long long>());
  while (vec[n].size() > 2) vec[n].pop_back();
}
long long calc(long long n) {
  if (n == 1 || vec[n].size() == 1) return vec[n][0];
  return max(vec[n][0], 1 + vec[n][1]);
}
int main() {
  long long cs, ts, i, j, k, x, y, z, q, m, n;
  scanf("%lld", &n);
  for (i = 2; i <= n + 1; i++) {
    scanf("%lld", &p[i]);
    add(i, 0);
    dp[i] = 1;
    long long cur = p[i], last = 1;
    while (cur) {
      add(cur, last);
      x = calc(cur);
      if (x <= dp[cur]) break;
      dp[cur] = last = x;
      cur = p[cur];
    }
    if (i > 2) printf(" ");
    printf("%lld", dp[1]);
  }
  printf("\n");
  return 0;
}
