#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e6 + 10, lg = 20;
long long int lvl[N], p[N][lg + 1];
vector<long long int> v[N];
void dfs(long long int u, long long int par) {
  lvl[u] = 1 + lvl[par];
  p[u][0] = par;
  for (auto j : v[u])
    if (j != par) dfs(j, u);
}
long long int lca(long long int u, long long int v) {
  if (lvl[u] < lvl[v]) swap(u, v);
  for (int i = lg; i >= 0; i--)
    if ((lvl[u] - (1 << i)) >= lvl[v]) u = p[u][i];
  if (u == v) return u;
  for (int i = lg; i >= 0; i--)
    if (p[u][i] != 0 && p[u][i] != p[v][i]) u = p[u][i], v = p[v][i];
  return p[u][0];
}
long long int dis(long long int u, long long int v) {
  return lvl[u] + lvl[v] - 2 * lvl[lca(u, v)];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int i, j, n, x, y, cur = 4, start = 2, end = 4, distance = 2;
  v[1].push_back(2);
  v[1].push_back(3);
  v[1].push_back(4);
  v[2].push_back(1);
  v[3].push_back(1);
  v[4].push_back(1);
  for (i = 0; i < lg; i++)
    for (j = 0; j <= 4; j++) p[i][j] = 0;
  lvl[0] = -1;
  dfs(1, 0);
  for (i = 1; i < lg; i++)
    for (j = 1; j <= 4; j++)
      if (p[j][i - 1] != -1) p[j][i] = p[p[j][i - 1]][i - 1];
  long long int q;
  cin >> q;
  while (q--) {
    cin >> x;
    v[x].push_back(cur + 1);
    v[x].push_back(cur + 2);
    v[cur + 1].push_back(x);
    v[cur + 2].push_back(x);
    lvl[cur + 1] = 1 + lvl[x];
    lvl[cur + 2] = 1 + lvl[x];
    p[cur + 1][0] = x;
    p[cur + 2][0] = x;
    for (i = 1; i <= lg; i++) {
      p[cur + 1][i] = p[p[cur + 1][i - 1]][i - 1];
      p[cur + 2][i] = p[p[cur + 1][i - 1]][i - 1];
    }
    if (dis(cur + 1, start) > distance) {
      distance = dis(cur + 1, start);
      end = cur + 1;
    }
    if (dis(cur + 1, end) > distance) {
      distance = dis(cur + 1, end);
      start = cur + 1;
    }
    cout << distance << "\n";
    cur += 2;
  }
  return 0;
}
