#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1e5 + 5;
const int M = 25;
int dep[N], a, b, n;
int f[N][M];
int GetLca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  int dif = dep[x] - dep[y];
  for (int j = 0; j < (M); j++)
    if (dif >> j & 1) x = f[x][j];
  if (x == y) return x;
  for (int j = M - 1; ~j; j--) {
    if (f[x][j] != f[y][j]) {
      x = f[x][j];
      y = f[y][j];
    }
  }
  return f[x][0];
}
int GetDis(int x, int y) {
  int lca = GetLca(x, y);
  int dis = dep[x] - dep[lca] + dep[y] - dep[lca];
  return dis;
}
int main() {
  int p, mx;
  scanf("%d", &n);
  memset(f, -1, sizeof(f));
  dep[0] = 0;
  mx = 0;
  int a = 0, b = 0;
  for (int i = 1; i < n; i++) {
    scanf("%d", &p);
    p--;
    dep[i] = dep[p] + 1;
    f[i][0] = p;
    for (int j = 1; j < M; j++)
      if (~f[i][j - 1]) f[i][j] = f[f[i][j - 1]][j - 1];
    int Dac = GetDis(a, i);
    if (Dac > mx) {
      mx = Dac;
      b = i;
    }
    int Dbc = GetDis(b, i);
    if (Dbc > mx) {
      mx = Dbc;
      a = i;
    }
    if (i > 1) printf(" ");
    printf("%d", mx);
  }
  return 0;
}
