#include <bits/stdc++.h>
using namespace std;
int deep[1000010];
int p[1000010][20];
void add(int x, int y) {
  deep[x] = deep[y] + 1;
  p[x][0] = y;
  for (int i = 1; i < 20; i++) p[x][i] = p[p[x][i - 1]][i - 1];
}
int lca(int x, int y) {
  if (deep[x] < deep[y]) swap(x, y);
  for (int i = 0; i < 20; i++)
    if ((deep[x] - deep[y]) & (1 << i)) x = p[x][i];
  for (int i = 19; i >= 0; i--)
    if (p[x][i] != p[y][i]) x = p[x][i], y = p[y][i];
  return p[x][0];
}
int find(int x, int y) { return deep[x] + deep[y] - (deep[lca(x, y)] << 1); }
int main() {
  ios::sync_with_stdio(0);
  int n = 4, st = 2, fn = 3, res = 2, Q;
  deep[1] = 3;
  deep[2] = deep[3] = deep[4] = 1;
  cin >> Q;
  while (Q--) {
    int v;
    cin >> v;
    add(++n, v);
    add(++n, v);
    if (find(st, n) > res)
      res++, fn = n;
    else if (find(fn, n) > res)
      res++, st = n;
    cout << res << "\n";
  }
  return 0;
}
