#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
long long n, q;
vector<long long> ad[N];
long long a[N];
long long pd[N][24];
long long dep[N];
void dfs(long long u, long long par) {
  for (long long i = 1, __c = 23; i <= __c; ++i)
    pd[u][i] = pd[pd[u][i - 1]][i - 1];
  for (auto &v : ad[u])
    if (v != par) {
      pd[v][0] = u;
      dep[v] = dep[u] + 1;
      dfs(v, u);
    }
}
long long lca(long long u, long long v) {
  if (dep[u] < dep[v]) swap(u, v);
  long long _ = dep[u] - dep[v];
  for (long long i = 23, __c = 0; i >= __c; --i)
    if (_ >> i & 1) u = pd[u][i];
  if (u == v) return u;
  for (long long i = 23, __c = 0; i >= __c; --i)
    if (pd[u][i] != pd[v][i]) u = pd[u][i], v = pd[v][i];
  return pd[u][0];
}
long long dist(long long u, long long v) {
  long long c = lca(u, v);
  return dep[u] + dep[v] - 2 * dep[c];
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> q;
  n = 4;
  for (long long i = 2, __c = 4; i <= __c; ++i) ad[1].push_back(i);
  for (long long i = 1, __c = q; i <= __c; ++i) {
    cin >> a[i];
    for (long long j = 0, __c = 1; j <= __c; ++j) ad[a[i]].push_back(++n);
  }
  dfs(1, -1);
  n = 4;
  long long x = 2, y = 3;
  for (long long i = 1, __c = q; i <= __c; ++i) {
    n += 2;
    long long d1 = dist(x, n), d2 = dist(n, y), d3 = dist(x, y);
    if (max(d1, d2) > d3) {
      if (d1 > d2)
        y = n;
      else
        x = n;
    }
    cout << dist(x, y) << '\n';
  }
}
