#include <bits/stdc++.h>
#pragma optimization_level 3
using namespace std;
long double TL = 1.0;
bool is_tl = 0;
long long CALLS = 0;
inline bool IS() {
  if (++CALLS == 1000) {
    CALLS = 0;
    is_tl |= clock() > (TL - 0.1) * CLOCKS_PER_SEC;
  }
  return is_tl;
}
template <typename T1, typename T2>
inline void amin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void amax(T1 &a, T2 b) {
  if (a < b) a = b;
}
template <typename T>
inline void print(T &a) {
  for (auto &U : a) cout << U << ' ';
  cout << '\n';
}
const long long N = 1e6 + 7, NS = 1e3 + 7, lg = 18, sq = 550, inf = 1e18 + 7,
                mod = 1e9 + 7, SM = 1e2 + 7;
const long double eps = 1e-9;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
long long up[N][lg], d[N], n = 0, a = 0, b = 0, ans = 0;
long long lca(long long x, long long y) {
  for (long long i = lg - 1; i >= 0; i--) {
    long long z = up[x][i];
    if (d[z] >= d[y]) x = z;
  }
  for (long long i = lg - 1; i >= 0; i--) {
    long long z = up[y][i];
    if (d[z] >= d[x]) y = z;
  }
  for (long long i = lg - 1; i >= 0; i--) {
    if (up[x][i] != up[y][i]) {
      x = up[x][i];
      y = up[y][i];
    }
  }
  return up[x][0];
}
long long get(long long x, long long y) {
  return d[x] + d[y] - 2 * d[lca(x, y)];
}
void add(long long v) {
  long long x = ++n;
  up[x][0] = v;
  d[x] = d[v] + 1;
  for (long long k = 1; k < lg; k++) up[x][k] = up[up[x][k - 1]][k - 1];
  long long cur = get(a, n);
  if (cur > ans) {
    ans = cur;
    a = a;
    b = n;
  }
  cur = get(n, b);
  if (cur > ans) {
    ans = cur;
    a = n;
    b = b;
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (long long i = 1; i < 4; i++) {
    add(0);
  }
  long long _;
  cin >> _;
  while (_--) {
    long long v;
    cin >> v;
    v--;
    add(v);
    add(v);
    cout << ans << '\n';
  }
}
