#include <bits/stdc++.h>
using namespace std;
const int lg = 21;
const int inf = 1000009;
int dp[inf][lg];
int lev[inf];
int lca(int a, int b) {
  if (lev[a] > lev[b]) swap(a, b);
  int d = lev[b] - lev[a];
  int r = 0;
  while (d) {
    if (d % 2) b = dp[b][r];
    r++;
    d /= 2;
  }
  if (a == b) return a;
  for (int i = lg - 1; i >= 0; --i)
    if (dp[a][i] != dp[b][i]) a = dp[a][i], b = dp[b][i];
  return a == b ? a : dp[a][0];
}
void add(int a, int p) {
  dp[a][0] = p;
  lev[a] = lev[p] + 1;
  for (int i = 1; i < lg; ++i) dp[a][i] = dp[dp[a][i - 1]][i - 1];
}
int calc(int a, int b) { return lev[a] + lev[b] - 2 * lev[lca(a, b)]; }
int main() {
  int q, bst, w1, w2, a, k, n = 4;
  scanf("%d", &q);
  add(1, 1);
  lev[1] = 0;
  add(2, 1);
  add(3, 1);
  add(4, 1);
  bst = 2;
  w1 = 2;
  w2 = 3;
  while (q--) {
    k = 2;
    scanf("%d", &a);
    while (k--) {
      add(++n, a);
      if (calc(n, w1) > bst)
        w2 = n, bst++;
      else if (calc(n, w2) > bst)
        w1 = n, bst++;
    }
    printf("%d\n", bst);
  }
}
