#include <bits/stdc++.h>
using namespace std;
const int Maxn = int(10e5) + 1000, MaxL = 30;
int par[Maxn][MaxL], dis[Maxn], q, diam = 2, nowver = 4, L;
pair<int, int> dia;
int getdis(int, int);
void add(int v, int parent) {
  par[v][0] = par[v + 1][0] = parent;
  for (int i = 1; i <= L; ++i)
    par[v][i] = par[v + 1][i] = par[par[v][i - 1]][i - 1];
  dis[v] = dis[v + 1] = dis[parent] + 1;
  int desfi = getdis(dia.first, v), desse = getdis(dia.second, v);
  if (desfi > diam) diam = desfi, dia.second = v;
  if (desse > diam) diam = desse, dia.first = v;
}
int lca(int x, int y) {
  if (dis[x] > dis[y]) swap(x, y);
  int des = dis[y] - dis[x];
  for (int i = L; i >= 0; --i)
    if ((des >> i) & 1) y = par[y][i];
  if (x == y) return x;
  for (int i = L; i >= 0; --i)
    if (par[x][i] != par[y][i]) x = par[x][i], y = par[y][i];
  return par[x][0];
}
int getdis(int x, int y) {
  int v = lca(x, y);
  return dis[x] + dis[y] - 2 * dis[v];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> q;
  for (int i = 0; (1 << i) < 2 * q + 10; ++i) L = i;
  dis[1] = dis[2] = dis[3] = 1;
  dia = make_pair(1, 2), diam = 2;
  for (int i = 0; i < q; ++i) {
    int v;
    cin >> v;
    --v;
    add(nowver, v);
    nowver += 2;
    cout << diam << '\n';
  }
  return 0;
}
