#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10 * 100000 + 100;
const int MAXB = 20 + 5;
bool mark[MAXN];
int q;
int par[MAXN][MAXB], hei[MAXN];
vector<int> path;
vector<int> adj[MAXN];
void Dfs(int v, int h) {
  if (h == 0) par[v][0] = v;
  for (int i = 1; i < 23; i++) par[v][i] = par[par[v][i - 1]][i - 1];
  mark[v] = true;
  hei[v] = h;
  for (int i = 0; i < (int)adj[v].size(); i++) {
    int temp = adj[v][i];
    if (!mark[temp]) {
      par[temp][0] = v;
      Dfs(temp, h + 1);
    }
  }
}
void Add(int u, int x) {
  adj[x].push_back(u);
  adj[u].push_back(x);
  mark[x] = true;
  hei[x] = hei[u] + 1;
  par[x][0] = u;
  for (int i = 1; i < 23; i++) par[x][i] = par[par[x][i - 1]][i - 1];
}
int Lca(int x, int y) {
  if (hei[x] > hei[y]) swap(x, y);
  int p = 19;
  while (hei[y] != hei[x]) {
    if (hei[par[y][p]] >= hei[x])
      y = par[y][p];
    else
      p--;
  }
  for (int p = 19; p >= 0; p--)
    if (par[x][p] != par[y][p]) x = par[x][p], y = par[y][p];
  return x == y ? x : par[x][0];
}
int main() {
  cin >> q;
  adj[1].push_back(2);
  adj[1].push_back(3);
  adj[1].push_back(4);
  adj[2].push_back(1);
  adj[3].push_back(1);
  adj[4].push_back(1);
  Dfs(1, 0);
  int cur = 5;
  int st = 2, en = 3, tul = 2;
  for (int i = 1; i <= q; i++) {
    int v;
    cin >> v;
    Add(v, cur);
    Add(v, cur + 1);
    int lc1 = Lca(cur, st);
    int lc2 = Lca(cur, en);
    int tul1 = hei[cur] + hei[st] - (2 * hei[lc1]);
    int tul2 = hei[cur] + hei[en] - (2 * hei[lc2]);
    if (tul1 > tul2) {
      if (tul1 > tul) {
        tul = tul1;
        en = cur;
      }
    } else {
      if (tul2 > tul) {
        tul = tul2;
        st = cur;
      }
    }
    cur += 2;
    cout << tul << endl;
  }
  return 0;
}
