#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 5;
const long long mod = 1e9 + 7;
const long long lg = 21;
long long dp[maxn][lg];
long long d[maxn];
long long lca(long long u, long long v) {
  long long ret = 0;
  if (d[u] < d[v]) swap(u, v);
  for (long long i = lg - 1; i >= 0; i--) {
    if (d[u] - d[v] >= (1 << i)) {
      u = dp[u][i];
      ret += (1 << i);
    }
  }
  if (u == v) return ret;
  for (long long i = lg - 1; i >= 0; i--) {
    if (dp[u][i] != dp[v][i]) {
      u = dp[u][i];
      v = dp[v][i];
      ret += (1 << (i + 1));
    }
  }
  return ret + 2;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  srand(time(0));
  long long q;
  cin >> q;
  long long n = 4;
  d[1] = d[2] = d[3] = 1;
  long long opt = 1;
  long long ans = 2;
  while (q--) {
    long long v;
    cin >> v;
    v--;
    n += 2;
    dp[n - 2][0] = dp[n - 1][0] = v;
    for (long long i = 1; i < lg; i++) {
      dp[n - 2][i] = dp[n - 1][i] = dp[dp[n - 1][i - 1]][i - 1];
    }
    d[n - 2] = d[n - 1] = d[v] + 1;
    if (d[opt] >= d[n - 2]) {
      ans = max(ans, lca(opt, n - 2));
    } else {
      ans++;
      opt = n - 2;
    }
    cout << ans << '\n';
  }
  return 0;
}
