#include <bits/stdc++.h>
using namespace std;
vector<int> ke[1100010];
int a[1100010], d[1100010];
int f[1100010][22];
bool ok[1100010];
int q, n = 4, k;
void dfs(int i, int par, int depth) {
  ok[i] = true;
  d[i] = depth;
  f[i][0] = par;
  for (int j = 1; j < 22; ++j) f[i][j] = f[f[i][j - 1]][j - 1];
  for (int j = 0; j < ke[i].size(); ++j) {
    int v = ke[i][j];
    if (!ok[v]) dfs(v, i, depth + 1);
  }
}
int dist(int x, int y) {
  int xx = x, yy = y;
  if (d[x] > d[y]) swap(x, y);
  if (d[x] != d[y]) {
    int z = d[y] - d[x];
    for (int j = 21; j >= 0; --j)
      if ((z >> j) & 1) y = f[y][j];
  }
  for (int j = 21; j >= 0; --j)
    if (f[x][j] != f[y][j]) x = f[x][j], y = f[y][j];
  int lca = (x != y ? f[x][0] : x);
  return d[xx] + d[yy] - 2 * d[lca];
}
int main() {
  ios::sync_with_stdio(false);
  cin >> q;
  for (int i = 0; i < q; ++i) cin >> a[i];
  ke[1].push_back(2), ke[2].push_back(1);
  ke[1].push_back(3), ke[3].push_back(1);
  ke[1].push_back(4), ke[4].push_back(1);
  for (int i = 0; i < q; ++i) {
    n++;
    ke[a[i]].push_back(n);
    ke[n].push_back(a[i]);
    n++;
    ke[a[i]].push_back(n);
    ke[n].push_back(a[i]);
  }
  for (int j = 0; j < 22; ++j) f[1][j] = 1;
  dfs(1, 1, 0);
  int nn = 4, x = 2, y = 4, res = 2;
  int arr[5];
  for (int i = 0; i < q; ++i) {
    arr[0] = x, arr[1] = y;
    arr[2] = ++nn, arr[3] = ++nn;
    int xx = x, yy = y;
    for (int j = 0; j < 3; ++j)
      for (int l = j + 1; l < 3; ++l) {
        int d = dist(arr[j], arr[l]);
        if (d > res) {
          res = d;
          xx = arr[j], yy = arr[l];
        }
      }
    x = xx, y = yy;
    cout << res << endl;
  }
  return 0;
}
