#include <bits/stdc++.h>
using namespace std;
int n;
multiset<pair<int, int> > s[1000002];
int pr[1000002];
int mx[1000002];
void add(int node, int val, int ff) {
  s[node].insert(make_pair(val, ff));
  while (s[node].size() > 2) {
    s[node].erase(s[node].begin());
  }
  auto it = s[node].rbegin();
  int nex = (*it).first;
  it++;
  nex = max(nex, (*it).first + 1);
  if (mx[node] != nex) {
    if (pr[node] >= 0) {
      if (s[pr[node]].count(make_pair(mx[node], node))) {
        s[pr[node]].erase(make_pair(mx[node], node));
      }
      add(pr[node], nex, node);
    }
    mx[node] = nex;
  }
}
int main() {
  pr[0] = -1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    s[i].insert({0, -1});
    s[i].insert({0, -2});
  }
  for (int i = 1; i <= n; i++) {
    int p;
    scanf("%d", &p);
    p--;
    pr[i] = p;
    mx[i] = 1;
    add(p, 1, i);
    if (i > 1) {
      printf(" ");
    }
    printf("%d", *s[0].rbegin());
  }
  puts("");
  return 0;
}
