#include <bits/stdc++.h>
using namespace std;
const int N = 2000003;
const int M = N << 1;
const int Lg = 25;
int n, q;
int dep[N], f[N][Lg];
void read(int &x) {
  char ch = getchar();
  x = 0;
  for (; ch < '0' || ch > '9'; ch = getchar())
    ;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = (x << 3) + (x << 1) + ch - '0';
}
int lca(int x, int y) {
  if (dep[x] < dep[y]) x ^= y ^= x ^= y;
  for (int i = Lg - 1; i >= 0; i--)
    if (dep[f[x][i]] >= dep[y]) x = f[x][i];
  if (x == y) return x;
  for (int i = Lg - 1; i >= 0; i--)
    if (f[x][i] != f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
inline int get_dist(int x, int y) {
  return dep[x] + dep[y] - 2 * dep[lca(x, y)];
}
int main() {
  n = 4;
  int x, L = 2, r = 3, mx = 2;
  f[2][0] = f[3][0] = f[4][0] = 1;
  dep[2] = dep[3] = dep[4] = 2;
  dep[1] = 1;
  read(q);
  while (q--) {
    read(x);
    ++n;
    f[n][0] = x;
    dep[n] = dep[x] + 1;
    for (int i = 1; i < Lg; i++) f[n][i] = f[f[n][i - 1]][i - 1];
    ++n;
    f[n][0] = x;
    dep[n] = dep[x] + 1;
    for (int i = 1; i < Lg; i++) f[n][i] = f[f[n][i - 1]][i - 1];
    int dis = get_dist(n, L);
    if (dis > mx) {
      mx = dis;
      r = n;
    } else {
      dis = get_dist(n, r);
      if (dis > mx) {
        mx = dis;
        L = n;
      }
    }
    printf("%d\n", mx);
  }
  return 0;
}
