#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1, ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch - '0');
    ch = getchar();
  }
  return f == 1 ? x : -x;
}
inline void print(int a[], int n, int offset) {
  for (int i = 0; i < n; i++) printf("%d ", a[i + offset]);
  printf("\n");
}
const int maxn = 1e6 + 10;
int n, m;
int fa[maxn], f[maxn], mx[maxn][2];
inline void doit() {
  n = read();
  f[1] = 1;
  for (int i = 2; i <= n + 1; i++) {
    fa[i] = read();
    f[i] = 1;
    int u = fa[i];
    if (!mx[u][0])
      mx[u][0] = 1;
    else if (!mx[u][1])
      mx[u][1] = 1;
    while (1) {
      if (u == 1) {
        f[u] = mx[u][0];
        break;
      }
      if (f[u] >= max(mx[u][0], mx[u][1] + 1)) break;
      f[u] = max(mx[u][0], mx[u][1] + 1);
      if (f[u] > mx[fa[u]][0])
        mx[fa[u]][0] = f[u];
      else if (f[u] > mx[fa[u]][1])
        mx[fa[u]][1] = f[u];
      u = fa[u];
    }
    printf("%d ", f[1]);
  }
  printf("\n");
}
int main() {
  doit();
  return 0;
}
