#include <bits/stdc++.h>
using namespace std;
const double eps = 0.000000000000001;
const int N = 1000020;
int dp[N][21], lgn = 20;
void ff() {
  int i, j;
  for (i = 1; i < N; i++)
    for (j = 0; j < 21; j++) dp[i][j] = -1;
}
int lev[N];
void add(int c, int p) {
  dp[c][0] = p;
  int i;
  lev[c] = (p == -1 ? 1 : lev[p] + 1);
  for (i = 1; i <= lgn; i++) {
    dp[c][i] = (dp[c][i - 1] == -1 ? -1 : dp[dp[c][i - 1]][i - 1]);
  }
}
int lca(int a, int b) {
  if (a == b) return a;
  if (lev[a] < lev[b]) swap(a, b);
  {
    int i;
    for (i = lgn; i >= 0; i--) {
      if (lev[a] - (1 << i) >= lev[b]) {
        a = dp[a][i];
      }
    }
  }
  if (a == b) return a;
  int i, j;
  for (i = lgn; i >= 0; i--) {
    if (dp[a][i] != -1 && dp[a][i] != dp[b][i]) {
      a = dp[a][i];
      b = dp[b][i];
    }
  }
  assert(dp[a][0] == dp[b][0]);
  return dp[a][0];
}
int dis(int a, int b) {
  int cc = lca(a, b);
  return lev[b] + lev[a] - 2 * lev[cc];
}
int main() {
  int q;
  lev[1] = 1;
  ff();
  add(2, 1);
  add(3, 1);
  add(4, 1);
  scanf("%d", &q);
  int xx = 5, mx = 2;
  int a = 2, b = 4;
  while (q--) {
    int v;
    scanf("%d", &v);
    add(xx, v);
    add(xx + 1, v);
    int cc = dis(xx, a), bb = b;
    if (cc > mx) {
      mx = cc;
      b = xx;
    }
    cc = dis(xx, bb);
    if (cc > mx) {
      mx = cc;
      a = xx;
      b = bb;
    }
    printf("%d\n", mx);
    xx += 2;
  }
  return 0;
}
