#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000005;
int n, tot, dp[maxn], pa[maxn], maxv[maxn];
int main() {
  scanf("%d", &n);
  dp[1] = pa[1] = maxv[tot = 1] = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &pa[++tot]);
    dp[tot] = 1, maxv[tot] = 0;
    int at = tot, p;
    while (p = pa[at]) {
      int newv = dp[at] + (dp[at] <= maxv[p]);
      maxv[p] = max(maxv[p], dp[at]);
      if (newv > dp[p])
        dp[at = p] = newv;
      else
        break;
    }
    printf("%d ", maxv[1]);
  }
  return 0;
}
