#include <bits/stdc++.h>
struct node {
  int m1, m2;
  int parent;
  int pre;
};
node S[1000010];
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    for (int i = 0; i <= n; i++) S[i].m1 = S[i].m2 = S[i].pre = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &S[i].parent);
      S[i].parent--;
    }
    for (int i = 1; i <= n; i++) {
      int cur = i;
      int ans = 1;
      while (cur != 0 && S[cur].pre != ans) {
        S[cur].pre = ans;
        cur = S[cur].parent;
        if (ans > S[cur].m1)
          S[cur].m2 = S[cur].m1, S[cur].m1 = ans;
        else if (ans > S[cur].m2)
          S[cur].m2 = ans;
        ans = S[cur].m1 > S[cur].m2 + 1 ? S[cur].m1 : S[cur].m2 + 1;
      }
      if (i != 1) putchar(' ');
      printf("%d", S[0].m1);
    }
    putchar('\n');
  }
  return 0;
}
