#include <bits/stdc++.h>
const int maxn = 1000000 + 1000;
const int logmaxn = 20;
int n, Q;
int L[maxn];
int fa[maxn];
int anc[maxn][logmaxn];
void add(int u, int pa) {
  fa[u] = pa;
  L[u] = L[pa] + 1;
  anc[u][0] = pa;
  for (int j = 1; (1 << j) < n; j++)
    if (anc[u][j - 1]) anc[u][j] = anc[anc[u][j - 1]][j - 1];
}
int LCA(int p, int q) {
  if (L[p] < L[q]) std::swap(p, q);
  int log;
  for (log = 1; (1 << log) <= L[p]; log++)
    ;
  log--;
  for (int i = log; i >= 0; i--)
    if (L[p] - (1 << i) >= L[q]) p = anc[p][i];
  if (p == q) return p;
  for (int i = log; i >= 0; i--)
    if (anc[p][i] && anc[p][i] != anc[q][i]) p = anc[p][i], q = anc[q][i];
  return fa[p];
}
int distance(int u, int v) {
  int l = LCA(u, v);
  return L[u] + L[v] - L[l] * 2;
}
int main() {
  scanf("%d", &Q);
  n = 4;
  fa[2] = fa[3] = fa[4] = 1;
  L[2] = L[3] = L[4] = 1;
  anc[2][0] = anc[3][0] = anc[4][0] = 1;
  int U = 2, V = 3, diameter = 2;
  while (Q--) {
    int p;
    scanf("%d", &p);
    add(++n, p);
    add(++n, p);
    int l1 = distance(n, U), l2 = distance(n, V);
    if (l1 >= l2 && l1 >= diameter) {
      V = n;
      diameter = l1;
    } else if (l2 >= l1 && l2 >= diameter) {
      U = n;
      diameter = l2;
    }
    printf("%d\n", diameter);
  }
  return 0;
}
