#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10, maxl = 21;
int par[maxn][maxl];
int h[maxn];
int x, y, d;
int n, q;
int lca(int v, int u) {
  if (h[v] < h[u]) return lca(u, v);
  for (int i = maxl - 1; i >= 0; i--)
    if (par[v][i] != -1 && h[par[v][i]] >= h[u]) v = par[v][i];
  if (v == u) return v;
  for (int i = maxl - 1; i >= 0; i--)
    if (par[v][i] != -1 && par[v][i] != par[u][i]) v = par[v][i], u = par[u][i];
  return par[v][0];
}
int dis(int v, int u) { return h[v] + h[u] - 2 * h[lca(v, u)]; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  memset(par, -1, sizeof par);
  x = 2, y = 3, d = 2, n = 4;
  h[2] = h[3] = h[4] = 1;
  par[2][0] = par[3][0] = par[4][0] = 1;
  cin >> q;
  for (int j = 1; j <= q; j++) {
    int v;
    cin >> v;
    n += 2;
    if (dis(v, x) == d) {
      y = n - 1;
      d++;
    } else if (dis(v, y) == d) {
      x = n - 1;
      d++;
    }
    h[n] = h[v] + 1, h[n - 1] = h[v] + 1;
    par[n - 1][0] = v, par[n][0] = v;
    for (int i = 1; i < maxl; i++)
      if (par[n][i - 1] != -1)
        par[n - 1][i] = par[n][i] = par[par[n][i - 1]][i - 1];
    cout << d << '\n';
  }
  return 0;
}
