#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000000 + 10;
const int NUM = 21;
int q;
int lc[MAX], rc[MAX], b[MAX], p[MAX][NUM], dep[MAX];
void dfs(int u, int d) {
  if (!u) return;
  dep[u] = d;
  dfs(lc[u], d + 1);
  dfs(rc[u], d + 1);
}
int LCA(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  int s = NUM - 1;
  while (dep[u] != dep[v]) {
    while (s > 0 && dep[p[u][s]] < dep[v]) --s;
    u = p[u][s];
  }
  s = NUM - 1;
  while (u != v) {
    while (s > 0 && p[u][s] == p[v][s]) --s;
    u = p[u][s];
    v = p[v][s];
  }
  return u;
}
int main() {
  int i;
  cin >> q;
  int tot = 4;
  for ((i) = (1); (i) <= (q); ++(i)) {
    scanf("%d", &b[i]);
    lc[b[i]] = ++tot;
    rc[b[i]] = ++tot;
    p[tot - 1][0] = p[tot][0] = b[i];
  }
  p[2][0] = p[3][0] = p[4][0] = 1;
  dep[1] = 1;
  dfs(2, 2);
  dfs(3, 2);
  dfs(4, 2);
  for (int j = 1; j < NUM; ++j)
    for ((i) = (1); (i) <= (tot); ++(i)) p[i][j] = p[p[i][j - 1]][j - 1];
  int nowl = 2, nowr = 3, dd = 2;
  for ((i) = (1); (i) <= (q); ++(i)) {
    int d = lc[b[i]];
    int flag = 0, nowlca;
    if (dep[nowl] + dep[d] - dep[nowlca = LCA(nowl, d)] * 2 > dd) {
      dd = dep[nowl] + dep[d] - dep[nowlca] * 2;
      flag = 1;
    }
    if (dep[nowr] + dep[d] - dep[nowlca = LCA(nowr, d)] * 2 > dd) {
      dd = dep[nowr] + dep[d] - dep[nowlca] * 2;
      flag = 2;
    }
    if (flag == 1)
      nowr = d;
    else if (flag == 2)
      nowl = d;
    printf("%d\n", dd);
  }
  return 0;
}
