#include <bits/stdc++.h>
const int MAXQ = 5e5 + 5;
using namespace std;
struct edge {
  int v, next;
} ed[MAXQ * 4];
int head[MAXQ * 2];
int topE;
void addE(int u, int v) {
  ed[++topE].v = v;
  ed[topE].next = head[u];
  head[u] = topE;
  return;
}
int dep[MAXQ * 2];
int fa[MAXQ * 2][25];
int Q;
int ans;
int topN;
int lca(int x, int y) {
  int res = 0;
  if (dep[x] < dep[y]) {
    swap(x, y);
  }
  res += dep[x] - dep[y];
  while (dep[x] != dep[y]) {
    x = fa[x][int(log2(dep[x] - dep[y]))];
  }
  for (int i = int(log2(dep[x])); i >= 0; --i) {
    if (fa[x][i] != fa[y][i]) {
      res += dep[x] - dep[fa[x][i]];
      res += dep[y] - dep[fa[y][i]];
      x = fa[x][i];
      y = fa[y][i];
    }
  }
  if (x == y) {
    return res;
  }
  x = fa[x][0];
  y = fa[y][0];
  res += 2;
  return res;
}
void insertNode(int u, int v) {
  fa[u][0] = v;
  dep[u] = dep[v] + 1;
  for (int i = 1; i <= int(log2(dep[u])); ++i) {
    fa[u][i] = fa[fa[u][i - 1]][i - 1];
  }
  return;
}
int da, db;
int main() {
  scanf("%d", &Q);
  topN = 4;
  dep[2] = dep[3] = dep[4] = 1;
  fa[2][0] = fa[3][0] = fa[4][0] = 1;
  da = 2;
  db = 3;
  ans = 2;
  for (int i = 1; i <= Q; ++i) {
    int v;
    scanf("%d", &v);
    insertNode(++topN, v);
    insertNode(++topN, v);
    if (lca(da, topN) > ans) {
      ans = lca(da, topN);
      db = topN;
    } else if (lca(db, topN) > ans) {
      ans = lca(db, topN);
      da = topN;
    }
    printf("%d\n", ans);
  }
  return 0;
}
