#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10, maxl = 20;
int par[maxn][maxl], h[maxn], v, n, diam;
int dis(int u, int v) {
  int res = 0;
  if (h[u] > h[v]) swap(u, v);
  for (int i = maxl - 1; i >= 0; i--)
    if (h[v] - (1 << i) >= h[u]) v = par[v][i], res += (1 << i);
  for (int i = maxl - 1; i >= 0; i--)
    if (par[u][i] != par[v][i])
      u = par[u][i], v = par[v][i], res += (1 << (i + 1));
  return res + 2;
}
int main() {
  int q;
  scanf("%d", &q);
  par[2][0] = par[3][0] = par[4][0] = 1;
  h[2] = h[3] = h[4] = 1;
  diam = 2;
  n = 4;
  v = 2;
  while (q--) {
    int u;
    scanf("%d", &u);
    h[n + 1] = h[n + 2] = h[u] + 1;
    par[n + 1][0] = par[n + 2][0] = u;
    for (int i = 1; i < maxl; i++) {
      par[n + 1][i] = par[par[n + 1][i - 1]][i - 1];
      par[n + 2][i] = par[par[n + 2][i - 1]][i - 1];
    }
    n += 2;
    if (h[n] > h[v])
      v = n, diam++;
    else
      diam = max(diam, dis(n, v));
    printf("%d\n", diam);
  }
  return 0;
}
