#include <bits/stdc++.h>
using namespace std;
int i, j, k, l, n, m, s, an, sum, tot, K;
const int N = 1100000;
int fa[N], a[N][2], f[N];
int e[N], next[N], go[N];
class com {
 public:
  bool operator()(const int &a, const int &b) { return a > b; }
};
multiset<int, com> q[N];
int main() {
  scanf("%d", &n);
  n++;
  f[1] = 1;
  q[0].insert(1);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &fa[i]);
    q[fa[i]].insert(1);
    f[i] = 1;
    int x = i;
    while (fa[x]) {
      int y = fa[x];
      int pr = f[y];
      int z = fa[y];
      multiset<int, com>::iterator t = q[z].find(pr);
      q[z].erase(t);
      multiset<int, com>::iterator k = q[y].begin();
      if ((y == 1) || (q[y].size() == 1))
        f[y] = *k;
      else {
        multiset<int, com>::iterator k2 = k;
        k2++;
        f[y] = max(*k, *k2 + 1);
      }
      q[z].insert(f[y]);
      if (pr == f[y]) break;
      x = fa[x];
    }
    printf("%d\n", f[1]);
  }
  return 0;
}
