#include <bits/stdc++.h>
using namespace std;
const int N = 1000100;
vector<int> val[N];
int n, p[N], dp[N];
void add(int node, int v) {
  val[node].push_back(v);
  sort(val[node].begin(), val[node].end());
  reverse(val[node].begin(), val[node].end());
  while (val[node].size() > 2) val[node].pop_back();
}
int calc(int node) {
  if (node == 1) {
    return val[node][0];
  }
  return max(val[node][0], val[node].size() > 1 ? 1 + val[node][1] : 0);
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n + 1; ++i) {
    scanf("%d", &p[i]);
    add(i, dp[i]);
    dp[i] = 1;
    int cur = p[i];
    int last = dp[i];
    while (cur) {
      add(cur, last);
      if (calc(cur) <= dp[cur]) break;
      dp[cur] = calc(cur);
      last = dp[cur];
      cur = p[cur];
    }
    if (i > 2) printf(" ");
    printf("%d", dp[1]);
  }
  puts("");
  return 0;
}
