#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000009;
const int maxlg = 21;
int L[maxn] = {0};
int par[maxn] = {0};
int dp[maxn][maxlg] = {{0}};
int n = 4;
void init() {
  par[1] = 0;
  par[2] = 1;
  par[3] = 1;
  par[4] = 1;
  L[1] = 1;
  L[2] = 2;
  L[3] = 2;
  L[4] = 2;
  for (int i = 1; i <= n; i++) {
    dp[i][0] = par[i];
  }
  for (int j = 1; (1 << j) < n; j++) {
    for (int i = 1; i <= n; i++) {
      if (dp[i][j - 1]) dp[i][j] = dp[dp[i][j - 1]][j - 1];
    }
  }
}
void add(int v, int p) {
  L[v] = L[p] + 1;
  par[v] = p;
  dp[v][0] = p;
  for (int j = 1; (1 << j) < n; j++) {
    if (dp[v][j - 1]) dp[v][j] = dp[dp[v][j - 1]][j - 1];
  }
}
int lca(int p, int q) {
  if (L[p] < L[q]) swap(p, q);
  int lim = 0;
  for (int lg = 1; (1 << lg) <= L[p]; lg++) {
    lim = lg;
  }
  for (int i = lim; i >= 0; --i) {
    if (L[p] - (1 << i) >= L[q]) p = dp[p][i];
  }
  if (p == q) return q;
  for (int i = lim; i >= 0; --i) {
    if (dp[p][i] && dp[p][i] != dp[q][i]) {
      p = dp[p][i];
      q = dp[q][i];
    }
  }
  return par[p];
}
int dis(int x, int y) { return L[x] + L[y] - 2 * L[lca(x, y)]; }
int main() {
  ios_base::sync_with_stdio(0);
  init();
  int q;
  scanf("%d", &q);
  int start = 2;
  int end = 4;
  int D = 3;
  while (q--) {
    int p;
    scanf("%d", &p);
    add(++n, p);
    add(++n, p);
    int d1 = dis(n, start);
    int d2 = dis(n, end);
    if (d1 > d2 and d1 >= D) {
      D = d1;
      end = n;
    } else if (d2 >= d1 and d2 >= D) {
      D = d2;
      start = n;
    }
    cout << D << endl;
  }
  return 0;
}
