#include <bits/stdc++.h>
#pragma GCC oprimize(2)
using namespace std;
const int maxn = 1000010;
inline int read() {
  int w = 1, p = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') p = p * 10 + ch - '0', ch = getchar();
  return w * p;
}
int n, dp[maxn], f[maxn], s[maxn], fa[maxn];
inline int cg(int v, int u) {
  int mx;
  if (dp[v] < s[u]) return 0;
  if (dp[v] > f[u])
    s[u] = f[u], f[u] = dp[v];
  else
    s[u] = dp[v];
  mx = max(f[u], s[u] + 1);
  if (dp[u] == mx) return 0;
  dp[u] = mx;
  return 1;
}
int main() {
  n = read();
  n++;
  fa[1] = 0, dp[1] = 1;
  for (register int i = 2; i <= n; ++i) {
    fa[i] = read();
    dp[i] = 1;
    for (int j = i; fa[j] && cg(j, fa[j]); j = fa[j])
      ;
    cout << f[1] << endl;
  }
  return 0;
}
