#include <bits/stdc++.h>
using namespace std;
int DP[1000050][20];
int L[1000050];
int lef, rig, ans, N, Q;
void preprocess() {
  L[1] = 1;
  L[2] = L[3] = L[4] = 2;
  N = 4;
  lef = 2;
  rig = 4;
  ans = 2;
  DP[1][0] = -1;
  DP[2][0] = DP[3][0] = DP[4][0] = 1;
}
int lca(int a, int b) {
  if (L[a] < L[b]) return lca(b, a);
  for (int i = 20 - 1; i >= 0; i--) {
    if (L[a] - (1 << i) >= L[b]) a = DP[a][i];
  }
  if (a == b) return a;
  for (int i = 20 - 1; i >= 0; i--) {
    if (DP[a][i] != DP[b][i]) a = DP[a][i], b = DP[b][i];
  }
  return DP[a][0];
}
int diam(int a, int b) { return L[a] + L[b] - 2 * L[lca(a, b)]; }
int main() {
  preprocess();
  scanf("%d", &Q);
  while (Q--) {
    int v;
    scanf("%d", &v);
    DP[N + 1][0] = v;
    DP[N + 2][0] = v;
    for (int i = 1; i < 20; i++) {
      DP[N + 1][i] = DP[DP[N + 1][i - 1]][i - 1];
      DP[N + 2][i] = DP[N + 1][i];
    }
    L[N + 1] = L[N + 2] = L[v] + 1;
    int fi, se;
    fi = diam(N + 1, lef);
    se = diam(N + 2, rig);
    if (fi > ans) {
      rig = N + 1;
      ans = fi;
    }
    if (se > ans) {
      lef = N + 2;
      ans = se;
    }
    N += 2;
    printf("%d\n", ans);
  }
  return 0;
}
