#include <bits/stdc++.h>
using namespace std;
const long double pi = acosl(-1.0);
const int N = 11 * 100000;
int p[20][N];
int h[N];
int n;
int za, zb, zl;
int get(int a, int b) {
  int ans = h[a] + h[b];
  for (int j = (int)(20) - 1; j >= 0; --j)
    if (h[p[j][a]] >= h[b]) a = p[j][a];
  for (int j = (int)(20) - 1; j >= 0; --j)
    if (h[p[j][b]] >= h[a]) b = p[j][b];
  if (a != b) {
    for (int j = (int)(20) - 1; j >= 0; --j)
      if (p[j][a] != p[j][b]) {
        a = p[j][a];
        b = p[j][b];
      }
    a = p[0][a];
    b = p[0][b];
    assert(a == b);
  }
  ans -= 2 * h[a];
  return ans;
}
void add(int v) {
  p[0][n] = v;
  for (int j = 0; j < (int)(20); ++j)
    if (j) p[j][n] = p[j - 1][p[j - 1][n]];
  h[n] = h[v] + 1;
  int ta = get(n, za);
  int tb = get(n, zb);
  if (ta >= tb && ta > zl) {
    zb = n;
    zl = ta;
  } else if (tb >= ta && tb > zl) {
    za = n;
    zl = tb;
  }
  ++n;
}
void solve() {
  memset(p, -1, sizeof p);
  h[0] = 0;
  p[0][0] = 0;
  n = 1;
  add(0);
  add(0);
  add(0);
  int T;
  scanf("%d", &T);
  for (int i = 0; i < (int)(T); ++i) {
    int v;
    scanf("%d", &v);
    --v;
    add(v);
    add(v);
    printf("%d\n", zl);
  }
}
int main() {
  solve();
  return 0;
}
