#include <bits/stdc++.h>
using namespace std;
int p[1000005], f[1000005];
set<pair<int, int> > s[1000005];
int main() {
  int n;
  scanf("%d", &n);
  n++;
  for (auto i = (1); i < n; i++) {
    scanf("%d", &p[i]);
    p[i]--;
    int x = i;
    while (x) {
      int cur = -1;
      if (s[x].empty())
        cur = 1;
      else if (s[x].size() == 1)
        cur = s[x].begin()->first;
      else {
        auto it = s[x].rbegin();
        int a = it->first;
        it++;
        int b = it->first;
        cur = max(a, b + 1);
      }
      if (f[x] == cur) break;
      s[p[x]].erase({f[x], x});
      f[x] = cur;
      s[p[x]].insert({f[x], x});
      x = p[x];
    }
    f[0] = s[0].rbegin()->first;
    printf("%d ", f[0]);
  }
  return 0;
}
