#include <bits/stdc++.h>
using namespace std;
const int N = 1000000 + 10;
const int LOG = 20;
int q, tot;
int dep[N];
int f[N][LOG];
int jump(int u, int d) {
  for (int i = 0; d; ++i, d >>= 1) {
    if (d & 1) u = f[u][i];
  }
  return u;
}
int getDist(int u, int v) {
  int ru = u, rv = v;
  if (dep[u] < dep[v]) {
    swap(u, v);
  }
  u = jump(u, dep[u] - dep[v]);
  for (int i = LOG - 1; i >= 0; --i) {
    if (f[u][i] != f[v][i]) {
      u = f[u][i];
      v = f[v][i];
    }
  }
  int lca = u;
  if (u != v) lca = f[lca][0];
  return dep[ru] + dep[rv] - 2 * dep[lca];
}
void solve() {
  tot = 4;
  for (int i = 0; i < LOG; ++i) {
    for (int j = 0; j < 4; ++j) {
      f[j][i] = 0;
    }
  }
  dep[0] = 0;
  dep[1] = dep[2] = dep[3] = 1;
  cin >> q;
  int u;
  int len = 2;
  int ru = 1, rv = 2;
  int tmp, tmp2, xx;
  for (int i = 0; i < q; ++i) {
    scanf("%d", &u);
    --u;
    tmp = getDist(u, ru);
    xx = ru;
    tmp2 = getDist(u, rv);
    if (tmp2 > tmp) {
      tmp = tmp2;
      xx = rv;
    }
    f[tot][0] = f[tot + 1][0] = u;
    for (int i = 1; i < LOG; ++i) {
      f[tot][i] = f[tot + 1][i] = f[f[tot][i - 1]][i - 1];
    }
    dep[tot] = dep[tot + 1] = dep[u] + 1;
    tot += 2;
    if (tmp + 1 > len) {
      len = tmp + 1;
      ru = tot - 1;
      rv = xx;
    }
    printf("%d\n", len);
  }
}
int main() {
  solve();
  return 0;
}
