#include <bits/stdc++.h>
using namespace std;
const int _N = 2e6 + 11;
const long long INF = 1e18 + 11;
const long long MOD = 1e9 + 7;
const double EPS = 1e-7;
int dp[_N][23], u = 2, v = 3, q, x, n = 4, lvl[_N], res = 2;
void add(int rt, int a) {
  dp[a][0] = rt;
  lvl[a] = lvl[rt] + 1;
  for (int i = 1; i < 22; i++) {
    dp[a][i] = dp[dp[a][i - 1]][i - 1];
  }
}
int lca(int u, int v) {
  while (lvl[u] != lvl[v]) {
    int diff = (int)log2(abs(lvl[u] - lvl[v]));
    if (lvl[u] > lvl[v]) {
      u = dp[u][diff];
    } else {
      v = dp[v][diff];
    }
  }
  if (u == v) return v;
  for (int i = 21; i >= 0; i--) {
    if (dp[u][i] != dp[v][i]) {
      u = dp[u][i];
      v = dp[v][i];
    }
  }
  return dp[v][0];
}
int dist(int u, int v) { return lvl[u] + lvl[v] - 2 * lvl[lca(u, v)]; }
signed main() {
  ios_base ::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cout << fixed;
  cout << setprecision(15);
  srand(time(NULL));
  for (int i = 2; i <= 4; i++) {
    dp[i][0] = 1;
    lvl[i] = 1;
  }
  cin >> q;
  while (q--) {
    cin >> x;
    add(x, ++n);
    add(x, ++n);
    int d1 = dist(u, n);
    int d2 = dist(v, n);
    if (d1 >= d2 && res <= d1) {
      v = n;
      res = d1;
    } else if (d1 <= d2 && res <= d2) {
      u = n;
      res = d2;
    }
    cout << res << '\n';
  }
  return 0;
}
