#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int m;
  cin >> m;
  const int N = 2 * m + 100;
  const int h = 32 - __builtin_clz(N);
  vector<vector<int>> pr(N, vector<int>(h));
  vector<int> depth(N);
  auto add = [&](int p, int x) { // p 为 x 的父节点
    depth[x] = depth[p] + 1;
    pr[x][0] = p;
    for (int j = 0; j < h; j++) {
      if (pr[x][j] == -1) {
        pr[x][j + 1] = -1;
      } else {
        pr[x][j + 1] = pr[pr[x][j]][j];
      }
    }
  };
  auto lca = [&](int x, int y) {
    if (depth[x] < depth[y]) {
      swap(x, y);
    }
    int d = depth[x] - depth[y];
    for (int j = 0; j < h; j++) {
      if ((d >> j) & 1) {
        x = pr[x][j];
      }
    }
    if (x == y) {
      return x;
    }
    for (int j = h - 1; j >= 0; j--) {
      if (pr[x][j] != -1 && pr[x][j] != pr[y][j]) {
        x = pr[x][j];
        y = pr[y][j];
      }
    }
    return pr[x][0];
  };
  int diam = 2;
  int dx = 1, dy = 2;
  add(0, 1); add(0, 2); add(0, 3);
  auto update = [&](int x, int y) {
    int z = lca(x, y);
    int dist = depth[x] + depth[y] - 2 * depth[z];
    if (dist > diam) {
      diam = dist;
      dx = x;
      dy = y;
    }
  };
  for (int i = 0, n = 4; i < m; i++, n += 2) {
    int x;
    cin >> x;
    x--;
    add(x, n); add(x, n + 1);
    update(dx, n); update(dy, n); // 把新插入的节点和原来的直径起点终点组合一下
    cout << diam << '\n';
  }
  cerr << "Time: " << double(clock()) / CLOCKS_PER_SEC << '\n';
  return 0;
}
