#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x);
template <typename T>
void write(T x);
template <typename T>
void writesp(T x);
template <typename T>
void writeln(T x);
const long long N = 5e5 + 5;
long long f[N << 1][20], d[N << 1];
long long m, cnt;
long long l, r;
inline long long lca(long long x, long long y) {
  if (d[x] < d[y]) swap(x, y);
  for (register long long i = 19; i >= 0; i--) {
    if (d[f[x][i]] >= d[y]) x = f[x][i];
  }
  if (x == y) return x;
  for (register long long i = 19; i >= 0; i--) {
    if (f[x][i] != f[y][i]) {
      x = f[x][i];
      y = f[y][i];
    }
  }
  return f[x][0];
}
inline long long calc(long long x, long long y) {
  return d[x] + d[y] - (d[lca(x, y)] << 1);
}
long long mx1, mx2, D;
inline void new_root(long long u) {
  ++cnt;
  f[cnt][0] = u;
  d[cnt] = d[u] + 1;
  for (register long long i = 1; i <= 19; i++)
    f[cnt][i] = f[f[cnt][i - 1]][i - 1];
  mx1 = calc(cnt, l);
  mx2 = calc(cnt, r);
  if (mx1 > D) D = mx1, r = cnt;
  if (mx2 > D) D = mx2, l = cnt;
  return;
}
int main() {
  f[2][0] = 1;
  f[3][0] = 1;
  f[4][0] = 1;
  d[1] = 1;
  d[2] = d[3] = d[4] = 2;
  cnt = 4;
  l = 2;
  r = 3;
  D = 2;
  read(m);
  long long u;
  while (m--) {
    read(u);
    new_root(u);
    new_root(u);
    writeln(D);
  }
}
template <typename T>
void read(T &x) {
  char wn = getchar();
  long long t = 1;
  x = 0;
  while (wn < '0' || wn > '9') {
    if (wn == '-') t = -1;
    wn = getchar();
  }
  while (wn >= '0' && wn <= '9') {
    x = x * 10 + wn - '0';
    wn = getchar();
  }
  x *= t;
}
template <typename T>
void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x <= 9) {
    putchar(x + '0');
    return;
  }
  write(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
void writeln(T x) {
  write(x);
  putchar('\n');
}
template <typename T>
void writesp(T x) {
  write(x);
  putchar(' ');
}
