#include <bits/stdc++.h>
using namespace std;
const int nil = 0, rot = 1, N = 200005;
int n, m1, m2;
int fa[N][20], dep[N];
int getlca(int x, int y) {
  if (x == rot) return x;
  if (y == rot) return y;
  if (x == y) return x;
  if (dep[x] < dep[y]) swap(x, y);
  for (int j = 19; j >= 0; --j) {
    if (dep[fa[x][j]] >= dep[y]) x = fa[x][j];
  }
  if (x == y) return x;
  for (int j = 19; j >= 0; --j) {
    if (fa[x][j] != fa[y][j]) {
      x = fa[x][j];
      y = fa[y][j];
    }
  }
  return fa[x][0];
}
int main() {
  scanf("%d", &n);
  int a, t, ans, ans1, ans2;
  memset(fa, 0, sizeof(fa));
  memset(dep, 0, sizeof(dep));
  m1 = m2 = rot;
  ans = 0;
  for (int i = 2; i <= n; ++i) {
    scanf("%d", &a);
    dep[i] = dep[a] + 1;
    fa[i][0] = a;
    for (int j = 1; j <= 19; ++j) {
      fa[i][j] = fa[fa[i][j - 1]][j - 1];
    }
    t = getlca(m1, i);
    ans1 = dep[i] + dep[m1] - dep[t] * 2;
    t = getlca(m2, i);
    ans2 = dep[i] + dep[m2] - dep[t] * 2;
    if (ans1 > ans) {
      if (ans2 > ans1) {
        ans = ans2;
        m1 = i;
      } else {
        ans = ans1;
        m2 = i;
      }
    } else if (ans2 > ans) {
      ans = ans2;
      m1 = i;
    }
    printf("%d\n", ans);
  }
  return 0;
}
