#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 9;
const int LOG = 30;
int q;
int n;
int dp[maxn][30];
int level[maxn];
int ptree[maxn];
int ext1, ext2;
int distancia = 2;
int logaritmo(int a) {
  int log = 0;
  for (int i = 0; (1 << i) <= a; i++) log++;
  log--;
  return log;
}
int lca(int v, int w) {
  if (level[v] < level[w]) swap(v, w);
  int dif = logaritmo(level[v] - level[w]);
  for (int i = dif; i >= 0 && level[v] != level[w]; i--) {
    if ((1 << i) <= (level[v] - level[w])) v = dp[v][i];
  }
  int log = logaritmo(level[v]);
  int p = w;
  for (int i = log; i >= 0 && v != w; i--) {
    if (dp[v][i] == dp[w][i])
      p = dp[v][i];
    else {
      v = dp[v][i];
      w = dp[w][i];
    }
  }
  return p;
}
void add(int v, int p) {
  level[v] = level[p] + 1;
  ptree[v] = p;
  dp[v][0] = p;
  for (int i = 1; i < LOG; i++) {
    dp[v][i] = dp[dp[v][i - 1]][i - 1];
  }
}
int dist(int a, int b, int anc) {
  return abs(level[a] - level[anc] + level[b] - level[anc]);
}
void solve(int v, int p) {
  if (p == ext1) {
    ext1 = v;
    distancia++;
  } else if (p == ext2) {
    ext2 = v;
    distancia++;
  } else {
    int l = lca(ext1, v);
    if (dist(v, ext1, l) > distancia) {
      ext2 = v;
      distancia = dist(v, ext1, l);
    } else if (dist(v, ext2, lca(v, ext2)) > distancia) {
      ext1 = v;
      distancia = dist(v, ext2, lca(v, ext2));
    }
  }
}
void init() {
  memset(dp, 0, sizeof(dp));
  memset(level, 0, sizeof(level));
  memset(ptree, 0, sizeof(ptree));
  distancia = 0;
}
int main() {
  add(2, 1);
  add(3, 1);
  add(4, 1);
  n = 4;
  ext1 = 2;
  ext2 = 3;
  cin >> q;
  int vert = 0;
  for (int i = 1; i <= q; i++) {
    scanf("%d", &vert);
    add(n + 1, vert);
    solve(n + 1, vert);
    add(n + 2, vert);
    solve(n + 2, vert);
    n += 2;
    cout << distancia << endl;
  }
  return 0;
}
