#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
const int INF = 1e9 + 9;
const int B = 1e9 + 7;
int n, p[N];
set<pair<int, int> > s[N];
int d[N];
int main() {
  scanf("%d", &n);
  ++n;
  for (int i = int(2); i <= int(n); ++i) {
    scanf("%d", &p[i]);
    d[i] = -1;
    for (int x = i; x > 1; x = p[x]) {
      int old = d[x];
      s[p[x]].erase(pair<int, int>(d[x], x));
      if (s[x].size() == 0)
        d[x] = 0;
      else {
        d[x] = s[x].rbegin()->first;
        if (s[x].size() > 1) {
          auto it = s[x].rbegin();
          ++it;
          d[x] = max(d[x], it->first + 1);
        }
      }
      s[p[x]].insert(pair<int, int>(d[x], x));
      while (s[p[x]].size() > 2) s[p[x]].erase(s[p[x]].begin());
      if (d[x] == old) break;
    }
    printf("%d ", s[1].rbegin()->first + 1);
  }
  return 0;
}
