#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int mx[maxn], mx2[maxn], p[maxn], MX[maxn], MX2[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  p[0] = -1;
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
    p[i]--;
    int cur = p[i], x = 1, prv = i;
    while (~cur) {
      if (x > mx2[cur] && (MX[cur] != prv) &&
          (MX2[cur] != prv || mx2[cur] < x)) {
        mx2[cur] = x;
        MX2[cur] = prv;
        if (mx2[cur] > mx[cur]) {
          swap(mx2[cur], mx[cur]);
          swap(MX2[cur], MX[cur]);
        }
      } else if (x > mx[cur] && MX[cur] == prv) {
        mx[cur] = x;
      } else {
        break;
      }
      x = max(mx[cur], mx2[cur] + 1);
      prv = cur;
      cur = p[cur];
    }
    cout << mx[0] << ' ';
  }
}
