#include <bits/stdc++.h>
using namespace std;
const int maxv = 1000005;
const int maxlogv = 22;
int V, n;
int root;
int parent[maxlogv][maxv];
int depth[maxv];
bool isroot[maxv];
void addedge(int v, int fa) {
  parent[0][v] = fa;
  depth[v] = depth[fa] + 1;
  for (int k = 0; k + 1 < maxlogv; k++)
    if (parent[k][v] < 0)
      parent[k + 1][v] = -1;
    else
      parent[k + 1][v] = parent[k][parent[k][v]];
}
int lca(int u, int v) {
  if (depth[u] > depth[v]) swap(u, v);
  for (int k = 0; k < maxlogv; k++)
    if ((depth[v] - depth[u]) >> k & 1) v = parent[k][v];
  if (u == v) return u;
  for (int k = maxlogv - 1; k >= 0; k--)
    if (parent[k][u] != parent[k][v]) {
      u = parent[k][u];
      v = parent[k][v];
    }
  return parent[0][u];
}
int q;
void print2() {
  for (int i = 0; i < n; i++) printf("%d ", depth[i]);
  puts("");
}
int main() {
  depth[0] = 0;
  depth[1] = 1;
  depth[2] = 1;
  depth[3] = 1;
  parent[0][0] = -1;
  parent[0][1] = 0;
  parent[0][2] = 0;
  parent[0][3] = 0;
  int l = 1, r = 2;
  n = 4;
  scanf("%d", &q);
  int dia = 2;
  while (q--) {
    int a;
    scanf("%d", &a);
    a--;
    addedge(n, a);
    addedge(n + 1, a);
    n += 2;
    V = n;
    int tl = lca(n - 2, l), tr = lca(n - 2, r);
    int len1 = depth[n - 2] + depth[l] - (depth[tl] << 1);
    int len2 = depth[n - 2] + depth[r] - (depth[tr] << 1);
    if (len1 > dia) {
      dia = len1;
      r = n - 2;
    } else if (len2 > dia) {
      dia = len2;
      l = n - 2;
    }
    printf("%d\n", dia);
  }
  return 0;
}
