#include <bits/stdc++.h>
using namespace std;
multiset<int> s[1000010];
int p[1000010], ans[1000010];
int calc(int x) {
  if (s[x].empty()) return 1;
  multiset<int>::iterator it = s[x].end();
  it--;
  if (x == 1)
    return (*it);
  else {
    int fi = *it;
    if (it == s[x].begin()) return (*it);
    it--;
    return max(fi, (*it) + 1);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  memset(ans, -1, sizeof ans);
  for (int i = 2, x; i <= n + 1; i++) {
    scanf("%d", &x);
    p[i] = x, x = i;
    s[p[x]].insert(ans[x]);
    while (x) {
      int v = calc(x);
      if (v == ans[x]) break;
      if (x > 1) s[p[x]].erase(s[p[x]].find(ans[x]));
      ans[x] = v;
      if (x > 1) s[p[x]].insert(v);
      x = p[x];
    }
    printf("%d ", ans[1]);
  }
  puts("");
}
