#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
constexpr bool typetest = 0;
constexpr int N = 1e6 + 5;
int n, par[N], dp[N], f[N], maxn[N];
void Read() { cin >> n; }
void Solve() {
  for (int i = 2; i <= n + 1; ++i) {
    int v;
    cin >> v;
    par[i] = v;
    v = i;
    dp[i] = 1;
    while (v != 1) {
      if (dp[v] > maxn[par[v]]) {
        maxn[par[v]] = dp[v];
        f[par[v]] = 1;
        if (dp[par[v]] == dp[v]) break;
        dp[par[v]] = dp[v];
      } else if (dp[v] == maxn[par[v]]) {
        ++f[par[v]];
        if (f[par[v]] > 1) {
          if (dp[par[v]] == maxn[par[v]] + 1) break;
          dp[par[v]] = maxn[par[v]] + 1;
        } else
          break;
      } else
        break;
      v = par[v];
    }
    cout << maxn[1] << ' ';
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t(1);
  if (typetest) cin >> t;
  for (int _ = 1; _ <= t; ++_) {
    Read();
    Solve();
  }
}
