#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chmin(T &x, const T &y) {
  if (x > y) x = y;
}
template <typename T>
void chmax(T &x, const T &y) {
  if (x < y) x = y;
}
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
const int N = 1e6 + 10;
int n, dep[N], f[N][30], tim = 4, posa, posb, len;
inline int LCA(int u, int v) {
  if (dep[u] >= dep[v]) swap(u, v);
  for (int i = 20; i >= 0; i--)
    if (dep[v] - (1 << i) >= dep[u]) v = f[v][i];
  if (u == v) return u;
  for (int i = 20; i >= 0; i--)
    if (f[v][i] != f[u][i]) v = f[v][i], u = f[u][i];
  return f[u][0];
}
int main() {
  n = read();
  int u, v, lca, maxx, disa, disb;
  dep[1] = 1;
  posa = 2, posb = 3, len = 2;
  dep[2] = dep[3] = dep[4] = 2;
  f[2][0] = f[3][0] = f[4][0] = 1;
  f[1][0] = 0;
  while (n--) {
    u = read();
    dep[tim + 2] = dep[tim + 1] = dep[u] + 1;
    f[tim + 1][0] = f[tim + 2][0] = u;
    tim++;
    for (int i = 0; f[tim][i]; i++) f[tim][i + 1] = f[f[tim][i]][i];
    tim++;
    for (int i = 0; f[tim][i]; i++) f[tim][i + 1] = f[f[tim][i]][i];
    if (posa == u)
      posa = tim, len++;
    else if (posb == u)
      posb = tim, len++;
    else {
      lca = LCA(tim, posa);
      disa = dep[tim] + dep[posa] - 2 * dep[lca];
      lca = LCA(tim, posb);
      disb = dep[tim] + dep[posb] - 2 * dep[lca];
      if (disa > len && disa >= disb)
        posb = tim, len = disa;
      else if (disb > len && disa <= disb)
        posa = tim, len = disb;
    }
    cout << len << endl;
  }
}
