#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int q, s, t, n, maxl;
int f[N][22], dpt[N];
void INIT() {
  memset(f, 0, sizeof(f));
  dpt[1] = 0;
  dpt[2] = dpt[3] = dpt[4] = 1;
  f[2][0] = f[3][0] = f[4][0] = 1;
  n = 4;
  s = 2;
  t = 4;
  maxl = 2;
}
void UPDATE(int u, int fa) {
  f[u][0] = fa;
  dpt[u] = dpt[fa] + 1;
  for (int i = 1; i <= 21; i++) f[u][i] = f[f[u][i - 1]][i - 1];
}
int LEN(int x, int y) {
  if (x == y) return 0;
  if (dpt[x] < dpt[y]) swap(x, y);
  int len = 0;
  for (int i = 21; i >= 0; i--)
    if (dpt[x] - (1 << i) >= dpt[y]) len += (1 << i), x = f[x][i];
  for (int i = 21; i >= 0; i--)
    if (f[x][i] != f[y][i]) len += 2 * (1 << i), x = f[x][i], y = f[y][i];
  if (x != y) len += 2;
  return len;
}
int main() {
  INIT();
  scanf("%d", &q);
  while (q--) {
    int x;
    scanf("%d", &x);
    UPDATE(n + 1, x);
    UPDATE(n + 2, x);
    int l = LEN(n + 1, s);
    if (l > maxl) {
      t = n + 1;
      maxl = l;
    }
    l = LEN(n + 1, t);
    if (l > maxl) {
      s = n + 1;
      maxl = l;
    }
    printf("%d\n", maxl);
    n += 2;
  }
  return 0;
}
