#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int kMaxN = 1e6 + 3;
vector<pair<int, int>> dp[kMaxN];
void add(int u, int v, int val) {
  bool done = false;
  for (auto& p : dp[u]) {
    if (p.second == v) {
      assert(p.first <= val);
      p.first = val;
      done = true;
      break;
    }
  }
  if (!done) {
    dp[u].emplace_back(val, v);
  }
  sort(dp[u].begin(), dp[u].end(), greater<pair<int, int>>{});
  if (dp[u].size() > 2) {
    dp[u].pop_back();
  }
}
int value(int u) {
  if (dp[u].empty()) {
    return -1;
  }
  int res = dp[u].front().first;
  if (dp[u].size() > 1) {
    res = max(res, dp[u][1].first + 1);
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> p(n + 1);
  p[0] = -1;
  int best = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
    --p[i];
    assert(dp[i].empty());
    int j = i, cur = 1;
    do {
      int prev_v = value(p[j]);
      add(p[j], j, cur);
      cur = value(p[j]);
      if (cur == prev_v) {
        break;
      }
      j = p[j];
    } while (p[j] != -1);
    assert(!dp[0].empty());
    cout << dp[0][0].first << ' ';
  }
  cout << '\n';
  return 0;
}
