#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;
int fa[MAXN][25], dep[MAXN];
int n, MaxLog;
int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (int i = MaxLog; ~i; i--)
    if (dep[fa[u][i]] >= dep[v]) u = fa[u][i];
  if (u == v) return u;
  for (int i = MaxLog; ~i; i--)
    if (fa[u][i] != fa[v][i]) u = fa[u][i], v = fa[v][i];
  return fa[u][0];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  MaxLog = (int)(log2(n) + 0.5);
  dep[2] = dep[3] = dep[4] = 1;
  fa[2][0] = fa[3][0] = fa[4][0] = 1;
  int x = 4, d = 2, dst = 4;
  for (int i = 1; i <= n; i++) {
    int u;
    cin >> u;
    dep[x + 2] = dep[x + 1] = dep[u] + 1;
    fa[x + 2][0] = fa[x + 1][0] = u;
    for (int k = 1; k <= MaxLog; k++)
      fa[x + 1][k] = fa[x + 2][k] = fa[fa[x + 1][k - 1]][k - 1];
    if (dep[x + 1] > dep[dst])
      dst = x + 1, d++;
    else
      d = max(d, dep[x + 1] + dep[dst] - (dep[lca(x + 1, dst)] << 1));
    x += 2;
    cout << d << endl;
  }
  return 0;
}
