#include <bits/stdc++.h>
using namespace std;
using cd = complex<double>;
const long long INF = 1e18;
const int mod = 1e9 + 7;
const double Pi = acos(-1);
void Fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
int n, p = 2, q = 3, ans = 2;
int sz = 4;
int Depth[1000005];
int Up[1000005][21];
int LCA(int u, int v) {
  if (Depth[u] < Depth[v]) {
    swap(u, v);
  }
  for (int i = 0; i <= 20; i++) {
    if ((Depth[u] - Depth[v]) & (1 << i)) {
      u = Up[u][i];
    }
  }
  for (int i = 20; i >= 0; i--) {
    if (Up[u][i] != Up[v][i]) {
      u = Up[u][i];
      v = Up[v][i];
    }
  }
  return Up[u][0];
}
signed main() {
  Fastio();
  cin >> n;
  Depth[2] = Depth[3] = Depth[4] = 1;
  Up[2][0] = Up[3][0] = Up[4][0] = 1;
  while (n--) {
    int node;
    cin >> node;
    Up[sz + 1][0] = node;
    Up[sz + 2][0] = node;
    Depth[sz + 1] = Depth[sz + 2] = Depth[node] + 1;
    for (int i = 1; i <= 20; i++) {
      Up[sz + 1][i] = Up[Up[sz + 1][i - 1]][i - 1];
      Up[sz + 2][i] = Up[Up[sz + 2][i - 1]][i - 1];
    }
    sz += 2;
    if (Depth[p] + Depth[sz] - 2 * Depth[LCA(p, sz)] > ans) {
      q = sz;
      ans++;
    }
    if (Depth[q] + Depth[sz] - 2 * Depth[LCA(q, sz)] > ans) {
      p = sz;
      ans++;
    }
    cout << ans << '\n';
  }
}
