#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  scanf("%d", &n);
  vector<int> p(n + 1, -1);
  vector<pair<int, int> > first(n + 1, make_pair(-1, -1)),
      second(n + 1, make_pair(-1, -1));
  vector<int> ans(n + 1, 0);
  int best = 0;
  for (int i = 1; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    --x;
    p[i] = x;
    ans[i] = 1;
    int cur = i;
    while (p[cur] > 0) {
      if (first[p[cur]].second == cur)
        first[p[cur]].first = ans[cur];
      else if (second[p[cur]].second == cur) {
        second[p[cur]].first = ans[cur];
        if (first[p[cur]].first < second[p[cur]].first)
          swap(first[p[cur]], second[p[cur]]);
      } else if (first[p[cur]].first < ans[cur]) {
        second[p[cur]] = first[p[cur]];
        first[p[cur]] = make_pair(ans[cur], cur);
      } else if (second[p[cur]].first < ans[cur])
        second[p[cur]] = make_pair(ans[cur], cur);
      int new_ans = max(first[p[cur]].first, second[p[cur]].first + 1);
      if (new_ans > ans[p[cur]]) {
        ans[p[cur]] = new_ans;
        cur = p[cur];
      } else
        break;
    }
    if (p[cur] == 0) best = max(best, ans[cur]);
    printf("%d ", best);
  }
  return 0;
}
