#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const int maxn = 1e6 + 12;
int n, par[maxn], mx1[maxn], mx2[maxn], x, mx, x2, ans[maxn];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  n++;
  par[0] = -1;
  for (int i = 1; i < n; i++) {
    cin >> x;
    par[i] = x - 1;
    for (x = i; par[x] != -1; x = par[x]) {
      mx = max(mx1[x], mx2[x] + 1);
      x2 = par[x];
      if (mx <= ans[x]) break;
      ans[x] = mx;
      if (mx > mx1[x2]) {
        mx2[x2] = mx1[x2];
        mx1[x2] = mx;
        continue;
      } else if (mx > mx2[x2]) {
        mx2[x2] = mx;
        continue;
      }
    }
    cout << mx1[0] << ' ';
  }
  return 0;
}
