#include <bits/stdc++.h>
using namespace std;
const int maxl = 23;
const int maxn = 1000 * 1000 + 21;
int q, s = 2, t = 3, n = 4, D = 2, par[maxn][maxl], h[maxn];
int find_par(int v, int x) {
  for (int i = maxl - 1; i >= 0; i--)
    if (x & (1 << i)) v = par[v][i];
  return v;
}
int lca(int u, int v) {
  if (h[u] > h[v]) swap(u, v);
  v = find_par(v, h[v] - h[u]);
  if (u == v) return v;
  for (int i = maxl - 1; i >= 0; i--)
    if (par[v][i] != par[u][i]) v = par[v][i], u = par[u][i];
  return par[v][0];
}
int main() {
  for (int i = 2; i <= 4; i++) par[i][0] = 1, h[i] = 1;
  cin >> q;
  for (int i = 0, v, L; i < q; i++) {
    cin >> v;
    par[n + 1][0] = v;
    par[n + 2][0] = v;
    h[n + 1] = h[n + 2] = h[v] + 1;
    for (int j = 1; j < maxl; j++)
      for (int i = n + 1; i <= n + 2; i++)
        par[i][j] = par[par[i][j - 1]][j - 1];
    L = lca(n + 1, s);
    if (h[n + 1] + h[s] - 2 * h[L] > D)
      D = h[n + 1] + h[s] - 2 * h[L], t = n + 1;
    L = lca(n + 2, t);
    if (h[n + 2] + h[t] - 2 * h[L] > D)
      D = h[n + 1] + h[t] - 2 * h[L], s = n + 2;
    cout << D << "\n";
    n += 2;
  }
}
