#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
int f[N], s[N], w[N];
int main() {
  int n;
  scanf("%d", &n);
  int ans = 1;
  for (int i = 2; i <= n + 1; i++) {
    scanf("%d", &f[i]);
    int id = i;
    w[id] = 1;
    while (id != 1) {
      ans = max(ans, w[id]);
      ans = max(ans, w[f[id]]);
      if (w[id] > w[f[id]]) {
        w[f[id]] = w[id];
        s[f[id]] = 1;
      } else if (w[id] == w[f[id]] && s[f[id]] == 0) {
        s[f[id]] = 1;
        break;
      } else if (w[id] == w[f[id]] && s[f[id]] == 1) {
        w[f[id]] = w[id] + 1;
        s[f[id]] = 0;
      } else
        break;
      id = f[id];
    }
    s[1] = 0;
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}
