#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n = 4, q, x, y;
int fa[N][20], dep[N];
int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (int j = 19; j >= 0; --j) {
    if (dep[fa[u][j]] >= dep[v]) u = fa[u][j];
  }
  if (u == v) return u;
  for (int j = 19; j >= 0; --j) {
    if (fa[u][j] != fa[v][j]) u = fa[u][j], v = fa[v][j];
  }
  return fa[u][0];
}
int dis(int u, int v) {
  int tmp = lca(u, v);
  return dep[u] + dep[v] - 2 * dep[tmp];
}
int main() {
  cin >> q, x = 2, y = 3;
  fa[2][0] = fa[3][0] = fa[4][0] = 1;
  dep[1] = 1, dep[2] = dep[3] = dep[5] = 2;
  while (q--) {
    int u;
    scanf("%d", &u);
    fa[++n][0] = u, dep[n] = dep[u] + 1;
    for (int j = 1; j <= 19; ++j) fa[n][j] = fa[fa[n][j - 1]][j - 1];
    if (dis(x, n) > dis(y, n)) {
      if (dis(x, n) > dis(x, y)) y = n;
    } else if (dis(y, n) > dis(x, y))
      x = n;
    fa[++n][0] = u, dep[n] = dep[u] + 1;
    for (int j = 1; j <= 19; ++j) fa[n][j] = fa[fa[n][j - 1]][j - 1];
    if (dis(x, n) > dis(y, n)) {
      if (dis(x, n) > dis(x, y)) y = n;
    } else if (dis(y, n) > dis(x, y))
      x = n;
    printf("%d\n", dis(x, y));
  }
  return 0;
}
