#include <bits/stdc++.h>
using namespace std;
int d[1001000], p[1001000], mx1[1001000], mx2[1001000];
int in() {
  char c;
  bool g = false;
  while (c = getchar(), c < '0' || c > '9')
    if (c == '-')
      g = true;
    else
      g = false;
  int x = 0;
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - 48;
    c = getchar();
  }
  return g ? -x : x;
}
void out(int x) {
  int len = 0, data[20];
  while (x) {
    data[len++] = x % 10;
    x /= 10;
  }
  if (!len) data[len++] = 0;
  if (data[0] != abs(data[0])) putchar('-');
  while (len--) putchar(abs(data[len]) + 48);
  putchar(' ');
}
int main() {
  int n = in();
  for (int i = 1; i <= n; i++) {
    int a = in();
    p[i] = a - 1;
    d[i] = 1;
    a = i;
    while (a) {
      mx2[p[a]] = max(mx2[p[a]], d[a]);
      if (mx1[p[a]] < mx2[p[a]]) swap(mx1[p[a]], mx2[p[a]]);
      if (d[p[a]] < max(mx1[p[a]], mx2[p[a]] + bool(p[a])))
        d[p[a]] = max(mx1[p[a]], mx2[p[a]] + bool(p[a]));
      else
        break;
      a = p[a];
    }
    out(d[0]);
  }
  putchar('\n');
  return 0;
}
