#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000000 + 10;
int dp[maxn], mx1[maxn], mx2[maxn], n, fa[maxn];
bool work(int x, int f) {
  if (!f) return false;
  if (dp[x] <= mx2[f])
    return false;
  else {
    if (dp[x] >= mx1[f]) {
      mx2[f] = mx1[f];
      mx1[f] = dp[x];
    } else
      mx2[f] = dp[x];
  }
  int vv = max(mx1[f], mx2[f] + 1);
  if (dp[f] == vv)
    return false;
  else {
    dp[f] = vv;
    return true;
  }
}
int main() {
  scanf("%d", &n);
  dp[1] = 1;
  for (int i = 2; i <= n + 1; i++) {
    scanf("%d", &fa[i]);
    dp[i] = 1;
    for (int t = i; work(t, fa[t]); t = fa[t])
      ;
    printf("%d\n", mx1[1]);
  }
  return 0;
}
