#include <bits/stdc++.h>
using namespace std;
int a[1000010][30], d[1000010], n, s, t, maxx;
inline int read() {
  int k = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    k = (k << 1) + (k << 3) + (ch ^ 48);
    ch = getchar();
  }
  return k * f;
}
void init() {
  memset(a, 0, sizeof(a));
  d[1] = 0;
  d[2] = d[3] = d[4] = 1;
  a[2][0] = a[3][0] = a[4][0] = 1;
  n = 4;
  s = 2;
  t = 4;
  maxx = 2;
}
void add(int u, int fa) {
  a[u][0] = fa;
  d[u] = d[fa] + 1;
  for (int i = 1; i <= 21; i++) a[u][i] = a[a[u][i - 1]][i - 1];
}
int js(int x, int y) {
  if (x == y) return 0;
  if (d[x] < d[y]) swap(x, y);
  int len = 0;
  for (int i = 21; i >= 0; i--)
    if (d[x] - (1 << i) >= d[y]) len += (1 << i), x = a[x][i];
  for (int i = 21; i >= 0; i--)
    if (a[x][i] != a[y][i]) len += 2 * (1 << i), x = a[x][i], y = a[y][i];
  if (x != y) len += 2;
  return len;
}
int main() {
  int q;
  cin >> q;
  init();
  while (q--) {
    int x;
    x = read();
    add(n + 1, x);
    add(n + 2, x);
    int kk = js(n + 1, s);
    if (kk > maxx) {
      t = n + 1;
      maxx = kk;
    }
    kk = js(n + 1, t);
    if (kk > maxx) {
      s = n + 1;
      maxx = kk;
    }
    cout << maxx << endl;
    n = n + 2;
  }
}
