#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
#pragma GCC target("avx")
using namespace std;
inline char gc() {
  static char buf[1 << 16], *p1 = buf, *p2 = buf;
  if (p1 == p2) {
    p2 = (p1 = buf) + fread(buf, 1, 1 << 16, stdin);
    if (p2 == p1) return EOF;
  }
  return *p1++;
}
template <class t>
inline t read(t &x) {
  char c = gc();
  bool f = 0;
  x = 0;
  while (!isdigit(c)) f |= c == '-', c = gc();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = gc();
  if (f) x = -x;
  return x;
}
template <class t>
inline void write(t x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
  }
}
const int N = 1e6 + 5;
int f[N], lc[N], rc[N], tr[N], n, m, pox, poy, dis;
bool tg[N];
bool notrt(int x) { return lc[f[x]] == x || rc[f[x]] == x; }
void rev(int x) {
  swap(lc[x], rc[x]);
  tg[x] ^= 1;
}
void pushup(int x) { tr[x] = tr[lc[x]] + tr[rc[x]] + 1; }
void pushdown(int x) {
  if (tg[x]) {
    if (lc[x]) rev(lc[x]);
    if (rc[x]) rev(rc[x]);
    tg[x] = 0;
  }
}
void pushall(int x) {
  if (notrt(x)) pushall(f[x]);
  pushdown(x);
}
void rotate(int x) {
  int y = f[x], z = f[y], k = rc[y] == x, w = k ? lc[x] : rc[x];
  if (notrt(y)) rc[z] == y ? rc[z] = x : lc[z] = x;
  if (!k)
    rc[x] = y, lc[y] = w;
  else
    lc[x] = y, rc[y] = w;
  if (w) f[w] = y;
  f[y] = x;
  f[x] = z;
  pushup(y);
}
void splay(int x) {
  pushall(x);
  while (notrt(x)) {
    int y = f[x], z = f[y];
    if (notrt(y)) rotate((lc[y] == x) ^ (lc[z] == y) ? x : y);
    rotate(x);
  }
  pushup(x);
}
void access(int x) {
  for (int y = 0; x; x = f[y = x]) {
    splay(x);
    rc[x] = y;
    pushup(x);
  }
}
void makeroot(int x) {
  access(x);
  splay(x);
  rev(x);
}
void split(int x, int y) {
  makeroot(x);
  access(y);
  splay(y);
}
void insert(int x, int fa) {
  int dis1, dis2;
  f[x] = fa;
  split(pox, x);
  dis1 = tr[x] - 1;
  split(poy, x);
  dis2 = tr[x] - 1;
  if (dis1 > dis) poy = x, dis = dis1;
  if (dis2 > dis) pox = x, dis = dis2;
}
signed main() {
  n = 4;
  f[2] = 1;
  f[3] = 1;
  f[4] = 1;
  dis = 2;
  pox = 2;
  poy = 3;
  read(m);
  while (m--) {
    int x;
    read(x);
    insert(++n, x);
    insert(++n, x);
    write(dis);
    puts("");
  }
}
