#include <bits/stdc++.h>
using namespace std;
int m, n, ans = 0, sum = 0, p;
int f[1000001], fa[1000001], q, pp, hh, qq;
inline int read() {
  register int s = 0, t = 0;
  register char ch = getchar();
  while (ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
  while (ch >= '0' && ch <= '9')
    s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
  return t ? -s : s;
}
struct node {
  int x, id;
};
node mx[1000001][3];
void update(int u) {
  for (int i = u; fa[i]; i = fa[i]) {
    hh = fa[i];
    p = mx[hh][1].x;
    q = mx[hh][2].x;
    pp = mx[hh][1].id;
    qq = mx[hh][2].id;
    if (f[i] >= p) {
      if (mx[hh][1].id == i)
        mx[hh][1].x = f[i];
      else if (mx[hh][2].id == i)
        swap(mx[hh][1], mx[hh][2]), mx[hh][1].x = f[i];
      else
        mx[hh][1].id = i, mx[hh][1].x = f[i], mx[hh][2].x = p,
        mx[hh][2].id = pp;
    } else if (f[i] >= mx[hh][2].x) {
      if (mx[hh][2].id != i)
        mx[hh][2].x = f[i], mx[hh][2].id = i;
      else
        mx[hh][2].x = f[i];
    } else
      break;
    if (hh == 1)
      f[hh] = max(mx[hh][1].x, mx[hh][2].x);
    else if (mx[hh][2].x + 1 > f[hh])
      f[hh] = mx[hh][2].x + 1;
    else if (mx[hh][1].x > f[hh])
      f[hh] = mx[hh][1].x;
    else
      break;
  }
}
int main() {
  n = read();
  for (int i = 2; i <= n + 1; i++) {
    fa[i] = read();
    f[i] = 1;
    update(i);
    printf("%d ", f[1]);
  }
  return 0;
}
