#include <bits/stdc++.h>
int par[1000050][21];
int dep[1000050];
int lca(int u, int v) {
  if (dep[u] > dep[v]) std::swap(u, v);
  for (int i = 20; i >= 0; i--) {
    if ((dep[v] - dep[u]) >> i & 1) {
      v = par[v][i];
    }
  }
  if (u == v) return u;
  for (int i = 20; i >= 0; i--) {
    if (par[u][i] != par[v][i]) {
      u = par[u][i];
      v = par[v][i];
    }
  }
  return par[u][0];
}
int dist(int u, int v) {
  int o = lca(u, v);
  return dep[v] + dep[u] - 2 * dep[o];
}
int main() {
  dep[1] = 1;
  for (int i = 2; i <= 4; i++) {
    par[i][0] = 1;
    dep[i] = dep[1] + 1;
  }
  int Q;
  int N = 4;
  scanf("%d", &Q);
  int pu = 2, pv = 4;
  int dis = 2;
  while (Q--) {
    int v;
    scanf("%d", &v);
    par[N + 1][0] = par[N + 2][0] = v;
    dep[N + 1] = dep[N + 2] = dep[v] + 1;
    for (int i = 1; i <= 20; i++) {
      par[N + 1][i] = par[par[N + 1][i - 1]][i - 1];
      par[N + 2][i] = par[par[N + 2][i - 1]][i - 1];
    }
    int d = dist(pu, pv);
    if (dist(pu, N + 2) > d) {
      pv = N + 2;
    }
    if (dist(pv, N + 2) > d) {
      pu = N + 2;
    }
    printf("%d\n", dist(pu, pv));
    N += 2;
  }
}
