#include <bits/stdc++.h>
using namespace std;
template <class T, class L>
bool smax(T& x, L y) {
  return x < y ? (x = y, 1) : 0;
}
template <class T, class L>
bool smin(T& x, L y) {
  return x > y ? (x = y, 1) : 0;
}
const int maxn = 1e6 + 17;
int par[maxn];
struct ND {
  int a, b, val, ua;
  ND() { a = b = 0, val = 1, ua = -1; }
  bool update(int x, int u) {
    if (x > a) return ua = u, b = a, a = x, val = max(a, b + 1), 1;
    if (x > b && u != ua) return b = x, val = max(a, b + 1), 1;
    return 0;
  }
} node[maxn];
void dfs(int v, int x = 0, int u = -17) {
  if ((node[v].update(x, u) || u == -17) && v) dfs(par[v], node[v].val, v);
}
int n;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> par[i], par[i]--;
    dfs(i);
    cout << node->a << ' ';
  }
  cout << '\n';
  return 0;
}
