#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const int INF = 0x3f3f3f3f;
const int mo = 1e9 + 7;
inline int ksm(int a, int b) {
  int ret = 1;
  for (; b; b >>= 1, a = 1ll * a * a % mo)
    if (b & 1) ret = 1ll * ret * a % mo;
  return ret;
}
inline int read() {
  char ch = getchar();
  int x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n = 4, m, f[N][21], dep[N];
struct node {
  int u, v, mx;
  bool operator<(const node &A) const { return mx < A.mx; }
} a;
int LCA(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 20; i >= 0; i--)
    if (dep[f[x][i]] >= dep[y]) x = f[x][i];
  if (x == y) return x;
  for (int i = 20; i >= 0; i--)
    if (f[x][i] != f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
int dist(int x, int y) {
  int lca = LCA(x, y);
  return dep[x] + dep[y] - 2 * dep[lca];
}
void add(int u) {
  int x = n + 1, y = n + 2;
  n += 2;
  dep[x] = dep[y] = dep[u] + 1;
  f[x][0] = f[y][0] = u;
  for (int i = 1; i <= 20; i++) f[x][i] = f[y][i] = f[f[x][i - 1]][i - 1];
  int xx = a.u, yy = a.v;
  node b = (node){xx, x, dist(xx, x)}, c = (node){xx, y, dist(xx, y)};
  node d = (node){yy, x, dist(yy, x)}, e = (node){yy, y, dist(yy, y)};
  node f = (node){xx, yy, dist(xx, yy)};
  if (a < b) a = b;
  if (a < c) a = c;
  if (a < d) a = d;
  if (a < e) a = e;
  if (a < f) a = f;
}
signed main() {
  dep[1] = 1;
  a.u = 2, a.v = 4, a.mx = 2;
  dep[2] = dep[3] = dep[4] = 2;
  f[1][0] = f[2][0] = f[3][0] = f[4][0] = 1;
  m = read();
  for (; m; m--) {
    int u = read();
    add(u);
    printf("%d\n", a.mx);
  }
  return 0;
}
