#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int n, m;
int dx, dy, d;
int par[1200000][21];
int depth[1200000];
void calcpar(int now) {
  int i;
  int su = 1;
  int pnow = par[now][0];
  for (i = 1; i < 21; i++) {
    if (pnow == -1) {
      par[now][i] = -1;
      continue;
    }
    par[now][i] = par[pnow][i - 1];
    pnow = par[now][i];
  }
}
int lca(int x, int y) {
  int i, diff;
  if (depth[x] < depth[y]) swap(x, y);
  diff = depth[x] - depth[y];
  for (i = 20; i >= 0; i--) {
    if (diff & (1 << i)) x = par[x][i];
  }
  if (x == y) return x;
  for (i = 20; i >= 0; i--) {
    if (par[x][i] != par[y][i]) x = par[x][i], y = par[y][i];
  }
  return par[x][0];
}
int main() {
  int i, j, k;
  n = 4;
  par[0][0] = -1, par[1][0] = 0, par[2][0] = 0, par[3][0] = 0;
  depth[0] = 0, depth[1] = depth[2] = depth[3] = 1;
  calcpar(0), calcpar(1), calcpar(2), calcpar(3);
  dx = 1, dy = 3, d = 2;
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    int x;
    scanf("%d", &x);
    x--;
    par[n][0] = x;
    par[n + 1][0] = x;
    depth[n] = depth[n + 1] = depth[x] + 1;
    calcpar(n);
    calcpar(n + 1);
    int s1 = depth[n] + depth[dx] - 2 * depth[lca(n, dx)];
    int s2 = depth[n] + depth[dy] - 2 * depth[lca(n, dy)];
    if (s1 >= s2 && s1 > d) {
      dy = n;
      d = s1;
    } else if (s2 >= s1 && s2 > d) {
      dx = n;
      d = s2;
    }
    printf("%d\n", d);
    n += 2;
  }
  return 0;
}
