#include <bits/stdc++.h>
using namespace std;
const int N = 1000100;
const int INF = 1061109567;
inline int read() {
  int x = 0;
  int w = 1;
  register int c = getchar();
  while (c ^ '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') w = -1, c = getchar();
  while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0', c = getchar();
  return x * w;
}
vector<int> G[N];
int dep[N], f[N][30];
int Q, v, cur_node, A, B, cur1, cur2, ans, Tmp_Dist;
inline void AddEdge(int u, int v) {
  G[u].push_back(v);
  G[v].push_back(u);
}
inline void Init() {
  AddEdge(1, 2), AddEdge(1, 3), AddEdge(1, 4);
  cur_node = 4;
  A = 2, B = 3;
  ans = 2;
  f[2][0] = f[3][0] = f[4][0] = 1;
  dep[1] = 1;
  dep[2] = dep[3] = dep[4] = 2;
}
inline void Update(int u, int v) {
  f[v][0] = u;
  dep[v] = dep[u] + 1;
  for (int i = 1; (1 << i) <= dep[v]; ++i) {
    f[v][i] = f[f[v][i - 1]][i - 1];
  }
}
inline int LCA(int _a, int _b) {
  if (dep[_a] < dep[_b]) {
    swap(_a, _b);
  }
  int a = _a, b = _b;
  for (int i = 25; i >= 0; --i) {
    if (dep[a] - (1 << i) < dep[b]) continue;
    a = f[a][i];
  }
  if (a == b) return a;
  for (int i = 25; i >= 0; --i) {
    if (f[a][i] == f[b][i]) continue;
    a = f[a][i];
    b = f[b][i];
  }
  return f[a][0];
}
inline int GetDist(int _a, int _b) {
  int __lca = LCA(_a, _b);
  return dep[_a] - dep[__lca] + dep[_b] - dep[__lca];
}
int main() {
  Init();
  Q = read();
  while (Q--) {
    v = read();
    AddEdge(v, ++cur_node);
    Update(v, cur_node);
    AddEdge(v, ++cur_node);
    Update(v, cur_node);
    cur1 = cur_node;
    Tmp_Dist = GetDist(cur1, A);
    if (Tmp_Dist > ans) {
      ans = Tmp_Dist;
      B = cur1;
    }
    Tmp_Dist = GetDist(cur1, B);
    if (Tmp_Dist > ans) {
      ans = Tmp_Dist;
      A = cur1;
    }
    printf("%d\n", ans);
  }
  return 0;
}
