#include <bits/stdc++.h>
using namespace std;
int n, p[1000005], f[1000005], g[1000005], idf[1000005], idg[1000005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n;
  for (int i = 2; i < n + 2; i++) {
    cin >> p[i];
    for (int x = i; x > 0; x = p[x]) {
      if (max(f[x], g[x] + 1) > f[p[x]]) {
        if (x == idf[p[x]]) {
          f[p[x]] = max(f[x], g[x] + 1);
        } else {
          g[p[x]] = f[p[x]];
          f[p[x]] = max(f[x], g[x] + 1);
          idg[p[x]] = idf[p[x]];
          idf[p[x]] = x;
        }
      } else if (max(f[x], g[x] + 1) > g[p[x]]) {
        if (x == idf[p[x]]) {
          break;
        } else {
          g[p[x]] = max(f[x], g[x] + 1);
          idg[p[x]] = x;
        }
      } else {
        break;
      }
    }
    cout << f[1] << " ";
  }
  cout << "\n";
  return 0;
}
