#include <bits/stdc++.h>
using namespace std;
int p[1000005], a[1000005], b[1000005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
    p[i]--;
    for (int x = i; x; x = p[x]) {
      int y = max(a[x], b[x] + 1);
      if (y > a[p[x]]) {
        a[p[x]] = y;
        if (a[p[x]] == b[p[x]] + 1) break;
      } else if (y > b[p[x]]) {
        b[p[x]] = y;
        if (b[p[x]] < a[p[x]]) break;
      } else
        break;
    }
    printf("%d ", max(a[0], b[0]));
  }
  return 0;
}
