#include <bits/stdc++.h>
using namespace std;
const int SZ = 5e5 + 5, MV = 1e6 + 10;
int q, nv, par[MV], d[MV];
int rmq[MV][21];
int lca(int a, int b) {
  if (d[a] > d[b]) swap(a, b);
  for (int i = 20; i >= 0; i--)
    if (d[b] - (1 << i) >= d[a]) b = rmq[b][i];
  if (a == b) return a;
  for (int i = 20; i >= 0; i--)
    if (rmq[a][i] != -1 && rmq[a][i] != rmq[b][i]) a = rmq[a][i], b = rmq[b][i];
  return par[a];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> q;
  nv = 2 * q + 7;
  par[2] = par[3] = par[4] = 1;
  d[2] = d[3] = d[4] = 1;
  int bvs[] = {2, 3}, dis = 2;
  for (int i = 0; i < q; i++) {
    int cv, v1 = 2 * i + 5, v2 = 2 * i + 6;
    cin >> cv;
    par[v1] = par[v2] = cv;
    d[v1] = d[v2] = d[cv] + 1;
    rmq[v1][0] = rmq[v2][0] = cv;
    for (int cd = 1; 1 << cd < nv; cd++)
      if (rmq[v1][cd - 1] != -1)
        rmq[v1][cd] = rmq[v2][cd] = rmq[rmq[v1][cd - 1]][cd - 1];
    for (int j = 0; j < 2; j++) {
      int lcar = lca(bvs[j], v1);
      int newd = d[bvs[j]] + d[v1] - 2 * d[lcar];
      if (newd > dis) bvs[1 - j] = v1, dis = newd;
    }
    cout << dis << '\n';
  }
}
