#include <bits/stdc++.h>
using namespace std;
template <class T, class L>
bool smax(T &x, L y) {
  return x < y ? (x = y, 1) : 0;
}
template <class T, class L>
bool smin(T &x, L y) {
  return y < x ? (x = y, 1) : 0;
}
const int maxn = 1e6 + 17, lg = 17 + 3;
int nq, par[maxn][lg], q[maxn], st[maxn], h[maxn], n, first, second, maxh, ans,
    amir_joon;
vector<int> g[maxn];
void make_amirjoon_happy(int v = 0) {
  st[v] = amir_joon++;
  for (int i = 1; i < lg; i++) par[v][i] = par[par[v][i - 1]][i - 1];
  for (auto u : g[v]) *par[u] = v, h[u] = h[v] + 1, make_amirjoon_happy(u);
}
void DeemoLovesInit() {
  n = 4;
  g[0] = {1, 2, 3};
  cin >> nq;
  for (int i = 0; i < nq; i++) {
    cin >> q[i], q[i]--;
    g[q[i]].push_back(n++);
    g[q[i]].push_back(n++);
  }
  make_amirjoon_happy();
}
int sina_is_happy(int v, int u) {
  int ans = h[v] + h[u];
  if (h[u] < h[v]) swap(v, u);
  for (int i = 0; i < lg; i++)
    if ((h[u] - h[v]) >> i & 1) u = par[u][i];
  for (int i = lg - 1; ~i; i--)
    if (par[v][i] != par[u][i]) v = par[v][i], u = par[u][i];
  return ans - 2 * h[v == u ? v : *par[v]];
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  DeemoLovesInit();
  first = 1, second = 3, maxh = 1, ans = 2, n = 4;
  for_each(q, q + nq, [](int &v) {
    if (h[v] == maxh) {
      ans++;
      maxh++;
      first = n++;
      second = n++;
    } else {
      if (smax(ans, max(sina_is_happy(v, first), sina_is_happy(v, second)) + 1))
        ;
      if (h[v] == maxh - 1) {
        if (st[n++] < st[first]) first = n - 1;
        if (st[n++] > st[second]) second = n - 1;
      } else
        n += 2;
    }
    cout << ans << '\n';
  });
  return 0;
}
