#include <bits/stdc++.h>
using namespace std;
const int N = 1000022, LG = 23;
int n, q;
vector<vector<int> > g(N);
int T[N], P[N][LG], L[N];
bool vis[N];
void dfs(int x, int level) {
  vis[x] = true;
  for (int i = 0; i <= ((int)(g[x]).size()) - 1; ++i) {
    int child = g[x][i];
    if (!vis[child]) {
      T[child] = x;
      L[child] = level + 1;
      dfs(child, level + 1);
    }
  }
}
void chRoot(int root) {
  T[root] = root;
  L[root] = 1;
  dfs(root, 1);
  for (int i = 1; i <= n; ++i)
    for (int j = 0; (1ll << j) < n; j++) P[i][j] = -1;
  for (int i = 1; i <= n; ++i) P[i][0] = T[i];
  for (int j = 1; (1ll << j) < n; j++)
    for (int i = 1; i <= n; ++i)
      if (P[i][j - 1] != -1) P[i][j] = P[P[i][j - 1]][j - 1];
}
int query(int p, int q) {
  if (L[p] < L[q]) swap(p, q);
  int log;
  for (log = 1; (1ll << log) <= L[p]; log++)
    ;
  log--;
  for (int i = log; i >= 0; --i)
    if (L[p] - (1ll << i) >= L[q]) p = P[p][i];
  if (p == q) return p;
  for (int i = log; i >= 0; i--)
    if (P[p][i] != -1 && P[p][i] != P[q][i]) p = P[p][i], q = P[q][i];
  return T[p];
}
int main() {
  n = 4;
  for (int i = 2; i <= 4; ++i) {
    g[1].push_back(i);
    g[i].push_back(1);
  }
  scanf("%d", &q);
  for (int i = 1; i <= q; ++i) {
    int x;
    scanf("%d", &x);
    g[x].push_back(++n);
    g[n].push_back(x);
    g[x].push_back(++n);
    g[n].push_back(x);
  }
  chRoot(1);
  n = 4;
  int u = 2, v = 3, ans = 2;
  while (q--) {
    n += 2;
    int d1 = L[n] + L[u] - 2 * L[query(n, u)];
    int d2 = L[n] + L[v] - 2 * L[query(n, v)];
    if (max(d1, d2) > ans) {
      if (d1 < d2) swap(d1, d2), swap(u, v);
      ans = d1;
      v = n;
    }
    printf("%d\n", ans);
  }
}
