#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int N = (int)1e6;
typedef int arr[N + 10];
int n;
arr dp, f, s, ft;
int Update(int x, int y) {
  if (dp[x] < s[y]) return 0;
  if (dp[x] > f[y])
    s[y] = f[y], f[y] = dp[x];
  else
    s[y] = dp[x];
  int upd = max(f[y], s[y] + 1);
  if (dp[y] == upd) return 0;
  return dp[y] = upd, 1;
}
int main() {
  scanf("%d\n", &n);
  n++;
  ft[1] = 0;
  dp[1] = 1;
  for (int i = 2; i <= n; ++i) {
    scanf("%d", ft + i), dp[i] = 1;
    for (int x = i; ft[x] && Update(x, ft[x]); x = ft[x])
      ;
    printf("%d\n", f[1]);
  }
  return 0;
}
