#include <bits/stdc++.h>
using namespace std;
int n, p[1000100], dp[1000100], mx[1000100], cnt[1000100];
inline void update(int u, int p) {
  if (p > mx[u])
    mx[u] = p, cnt[u] = 1;
  else if (p == mx[u])
    cnt[u]++;
}
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
template <class T>
inline int read(T &x) {
  char c = gc(), b = 1;
  for (; !(c >= '0' && c <= '9' || c == EOF); c = gc())
    if (c == '-') b = -b;
  if (c == EOF) return 0;
  for (x = 0; c >= '0' && c <= '9'; x = x * 10 + c - '0', c = gc())
    ;
  x *= b;
  return 1;
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) {
    int u = i + 1;
    read(p[u]);
    dp[u] = 1;
    while (1) {
      int v = p[u];
      update(v, dp[u]);
      if (v == 1 || dp[v] > dp[u]) break;
      if (cnt[v] > 1 || dp[v] < dp[u])
        dp[v]++;
      else
        break;
      u = v;
    }
    printf("%d ", mx[1]);
  }
  return 0;
}
