#include <bits/stdc++.h>
const int maxn = 1000010;
int fa[maxn][30], deep[maxn], x, node1, node2, q, ans;
int lca(int a, int b) {
  if (deep[a] < deep[b]) std::swap(a, b);
  if (deep[a] != deep[b]) {
    int w = deep[a] - deep[b];
    for (int i = 0; i <= 20; ++i)
      if (w & (1 << i)) a = fa[a][i];
  }
  if (a == b) return a;
  for (int i = 20; i >= 0; --i)
    if (fa[a][i] != fa[b][i]) {
      a = fa[a][i];
      b = fa[b][i];
    }
  return fa[a][0];
}
int main() {
  scanf("%d", &q);
  fa[2][0] = 1;
  fa[3][0] = 1;
  fa[4][0] = 1;
  deep[2] = deep[3] = deep[4] = 1;
  node1 = 2;
  node2 = 3;
  ans = 2;
  for (int i = 1; i <= q; ++i) {
    scanf("%d", &x);
    fa[i * 2 + 3][0] = x;
    fa[i * 2 + 4][0] = x;
    deep[i * 2 + 3] = deep[x] + 1;
    deep[i * 2 + 4] = deep[x] + 1;
    for (int j = 1; j <= 20; ++j) {
      if (fa[i * 2 + 3][j - 1] == 0) break;
      fa[i * 2 + 3][j] = fa[fa[i * 2 + 3][j - 1]][j - 1];
      fa[i * 2 + 4][j] = fa[fa[i * 2 + 3][j - 1]][j - 1];
    }
    int c1 = lca(i * 2 + 3, node1);
    if (deep[node1] + deep[i * 2 + 3] - 2 * deep[c1] > ans) {
      ans = deep[node1] + deep[i * 2 + 3] - 2 * deep[c1];
      node2 = i * 2 + 3;
    }
    int c2 = lca(i * 2 + 4, node2);
    if (deep[node2] + deep[i * 2 + 4] - 2 * deep[c2] > ans) {
      ans = deep[node2] + deep[i * 2 + 4] - 2 * deep[c2];
      node1 = i * 2 + 4;
    }
    printf("%d\n", ans);
  }
  return 0;
}
