#include <bits/stdc++.h>
const int inf = 0xfffffff;
const long long INF = 1ll << 61;
using namespace std;
int num[1000000 + 5];
int b[1000000 + 5];
int c[1000000 + 5];
int n;
int ans;
void init() {
  memset(num, 0, sizeof(num));
  memset(b, 0, sizeof(b));
  memset(c, 0, sizeof(c));
  ans = 0;
}
bool input() {
  while (scanf("%d", &n) == 1) {
    return false;
  }
  return true;
}
void cal() {
  n++;
  for (int i = 2; i <= n; i++) {
    scanf("%d", &num[i]);
    b[i] = 1;
    c[i] = 0;
    int j = i;
    if (ans < b[j]) ans = b[j];
    while (num[j] != 1) {
      if (ans < b[j]) ans = b[j];
      if (ans < b[num[j]]) ans = b[num[j]];
      if (b[num[j]] < b[j]) {
        b[num[j]] = b[j];
        c[num[j]] = 1;
      } else if (c[num[j]] == 1 && b[num[j]] == b[j]) {
        b[num[j]] = b[j] + 1;
        c[num[j]] = 0;
      } else if (c[num[j]] == 0 && b[num[j]] == b[j]) {
        c[num[j]] = 1;
        break;
      } else
        break;
      if (ans < b[num[j]]) ans = b[num[j]];
      j = num[j];
    }
    printf("%d%c", ans, i == 1 ? '\n' : ' ');
  }
}
void output() {}
int main() {
  while (true) {
    init();
    if (input()) return 0;
    cal();
    output();
  }
}
