#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, p[1000005];
vector<int> v[1000005];
inline char nc() {
  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>
void read(T &x) {
  char c = nc(), b = 1;
  for (; !((c >= '0' && c <= '9') || c == EOF); c = nc())
    if (c == '-') b = -b;
  for (x = 0; c >= '0' && c <= '9'; x = x * 10 + c - '0', c = nc())
    ;
  x *= b;
}
using pii = pair<int, int>;
int up, ans[1000005];
int dp[1000005], mx[1000005][2];
int solve(int k) {
  up = k;
  for (int i = 1; i <= up; i++) mx[i][0] = mx[i][1] = 0;
  for (int i = up; i >= 2; i--) {
    if (!mx[i][0])
      dp[i] = 1;
    else {
      dp[i] = max(mx[i][0], mx[i][1] + 1);
    }
    int k = p[i];
    if (mx[k][1] < dp[i]) mx[k][1] = dp[i];
    if (mx[k][0] < mx[k][1]) swap(mx[k][1], mx[k][0]);
  }
  return mx[1][0];
}
void calc(int L, int R, int al, int ar) {
  if (R <= L + 1) return;
  if (al == ar) {
    for (int i = L + 1; i < R; i++) ans[i] = al;
    return;
  }
  int mid = L + R >> 1;
  ans[mid] = solve(mid);
  calc(L, mid, al, ans[mid]);
  calc(mid, R, ans[mid], ar);
  return;
}
int main() {
  read(n);
  for (int i = 2; i <= n + 1; i++) {
    read(p[i]);
  }
  int mx = solve(n + 1);
  ans[n + 1] = mx, ans[2] = 1;
  calc(2, n + 1, 1, mx);
  for (int i = 2; i <= n + 1; i++) printf("%d ", ans[i]);
  puts("");
  return 0;
}
