#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 10;
int h[2 * MAXN];
int p[30];
int father[2 * MAXN][30];
int dis(int A, int B) {
  int a, b;
  if (h[A] > h[B]) {
    a = A;
    b = B;
  } else {
    a = B;
    b = A;
  }
  int ans = h[a] - h[b];
  int k = ans, a1 = a;
  for (int i = 0; i < 30; ++i) {
    if (k % 2) a1 = father[a1][i];
    k /= 2;
  }
  int now = 29;
  while (a1 != b) {
    while (father[a1][now] == father[b][now] && now >= 0) --now;
    if (now == -1) now = 0;
    ans += p[now + 1];
    a1 = father[a1][now];
    b = father[b][now];
  }
  return ans;
}
int main() {
  p[0] = 1;
  for (int i = 1; i < 30; ++i) p[i] = 2 * p[i - 1];
  h[1] = 0;
  h[2] = h[3] = h[4] = 1;
  for (int i = 0; i < 30; ++i) {
    father[1][i] = father[2][i] = father[3][i] = father[4][i] = 1;
  }
  int q, a1, now = 4;
  int max = 2, left = 2, right = 3;
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &a1);
    ++now;
    h[now] = h[a1] + 1;
    for (int i = 0; i < 30; ++i) {
      if (i)
        father[now][i] = father[father[now][i - 1]][i - 1];
      else
        father[now][i] = a1;
    }
    ++now;
    h[now] = h[a1] + 1;
    for (int i = 0; i < 30; ++i) {
      if (i)
        father[now][i] = father[father[now][i - 1]][i - 1];
      else
        father[now][i] = a1;
    }
    if (dis(now, right) > max) {
      left = now;
      ++max;
    }
    if (dis(now, left) > max) {
      right = now;
      ++max;
    }
    printf("%d\n", max);
  }
  return 0;
}
