#include <bits/stdc++.h>
using namespace std;
const int inv = 1000000000;
const int minv = -inv;
const int max_q = 500010;
const int max_n = 2 * max_q + 4;
const int max_logn = 20;
int q, n;
int anc[max_n][max_logn];
int depth[max_n];
int ch[max_n][3];
int stym[max_n], ftym[max_n], tym = 0;
void setanc(int i) {
  for (int j = 1; j < max_logn; ++j) {
    if (anc[i][j - 1] == (-1)) break;
    anc[i][j] = anc[anc[i][j - 1]][j - 1];
  }
}
bool isanc(int u, int v) {
  return ((u == (-1)) or (stym[u] <= stym[v] and ftym[v] <= ftym[u]));
}
int binsrc(int l, int ix, int ref) {
  if (ix == 0)
    return anc[l][0];
  else {
    int mid = anc[l][ix - 1];
    if (isanc(mid, ref))
      return binsrc(l, ix - 1, ref);
    else
      return binsrc(mid, ix - 1, ref);
  }
}
int lca(int u, int v) {
  if (isanc(u, v))
    return u;
  else
    return binsrc(u, max_logn, v);
}
int fdist(int u, int v) {
  int x = lca(u, v);
  return (depth[u] + depth[v] - 2 * depth[x]);
}
void DFS(int vt) {
  stym[vt] = (tym++);
  for (int i = 0; i < 3; ++i) {
    if (vt != 0 and i == 2) break;
    int nb = ch[vt][i];
    if (nb != (-1)) {
      depth[nb] = depth[vt] + 1;
      DFS(nb);
    }
  }
  ftym[vt] = (tym++);
}
int main() {
  scanf("%d", &q);
  n = 4;
  for (int i = 0; i < max_n; ++i) {
    ch[i][0] = -1;
    ch[i][1] = -1;
    for (int j = 0; j < max_logn; ++j) anc[i][j] = -1;
  }
  anc[1][0] = 0;
  ch[0][0] = 1;
  anc[2][0] = 0;
  ch[0][1] = 2;
  anc[3][0] = 0;
  ch[0][2] = 3;
  for (int z = 0; z < q; ++z) {
    int p;
    scanf("%d", &p);
    --p;
    anc[n][0] = p;
    setanc(n);
    ch[p][0] = n;
    ++n;
    anc[n][0] = p;
    setanc(n);
    ch[p][1] = n;
    ++n;
  }
  depth[0] = 0;
  tym = 0;
  DFS(0);
  int a = 1, b = 2, d = 2;
  for (int i = 4; i < n; ++i) {
    if (fdist(a, i) > d) {
      b = i;
      d = fdist(a, b);
    }
    if (fdist(i, b) > d) {
      a = i;
      d = fdist(a, b);
    }
    if (i % 2 == 1) printf("%d\n", d);
  }
  return 0;
}
