#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
int maxx[N], max2[N], n, fa[N], dp[N];
bool dfs(int lx, int ly) {
  if (dp[lx] < max2[ly]) return 0;
  if (dp[lx] > maxx[ly])
    max2[ly] = maxx[ly], maxx[ly] = dp[lx];
  else
    max2[ly] = dp[lx];
  int upd = max(maxx[ly], max2[ly] + 1);
  if (dp[ly] == upd) return 0;
  return dp[ly] = upd, 1;
}
int main() {
  int i, j;
  cin >> n;
  dp[1] = 1;
  for (i = 2; i <= n + 1; i++) {
    scanf("%d", &fa[i]);
    dp[i] = 1;
    for (j = i; fa[j] && dfs(j, fa[j]); j = fa[j])
      ;
    cout << maxx[1] << '\n';
  }
  return 0;
}
