#include <bits/stdc++.h>
using namespace std;
int par[((int)1e6 + 1000)][21], dis[((int)1e6 + 1000)], ans = 2, mx = 2;
int lca(int x, int y) {
  if (dis[x] < dis[y]) swap(x, y);
  for (__typeof(0) i = (21) - ((21) > (0)); i != (0) - ((21) > (0));
       i += 1 - 2 * ((21) > (0)))
    if (dis[x] - (1 << i) >= dis[y]) x = par[x][i];
  if (x == y) return x;
  for (__typeof(0) i = (21) - ((21) > (0)); i != (0) - ((21) > (0));
       i += 1 - 2 * ((21) > (0)))
    if (par[x][i] != par[y][i]) x = par[x][i], y = par[y][i];
  return par[x][0];
}
int main() {
  int q, n = 4;
  cin >> q;
  dis[2] = dis[3] = dis[4] = par[2][0] = par[3][0] = par[4][0] = 1;
  while (q--) {
    int x;
    scanf("%d", &x);
    par[n + 1][0] = par[n + 2][0] = x;
    n += 2;
    for (__typeof(21) i = (1) - ((1) > (21)); i != (21) - ((1) > (21));
         i += 1 - 2 * ((1) > (21)))
      par[n][i] = par[n - 1][i] = par[par[n][i - 1]][i - 1];
    dis[n] = dis[n - 1] = dis[x] + 1;
    if (dis[n] > dis[mx])
      mx = n, ans++;
    else
      ans = max(ans, dis[n] + dis[mx] - 2 * dis[lca(mx, n)]);
    printf("%d\n", ans);
  }
}
