#include <bits/stdc++.h>
using namespace std;
ifstream fi;
char Buffer[32768];
void io_set() {
  fi.open("test.inp");
  cin.rdbuf(fi.rdbuf());
}
int P[1000010][20];
int A[500010], L[500010];
int n, q;
void enter() {
  n = 4;
  P[2][0] = P[3][0] = P[4][0] = L[2] = L[3] = L[4] = 1;
  cin >> q;
  for (int i = 1; i <= q; ++i) {
    cin >> A[i];
    P[++n][0] = A[i];
    L[n] = L[A[i]] + 1;
    P[++n][0] = A[i];
    L[n] = L[A[i]] + 1;
  }
}
void init() {
  int i, j;
  for (j = 1; 1 << j < n; ++j)
    for (i = 1; i <= n; ++i) P[i][j] = P[P[i][j - 1]][j - 1];
}
inline int LCA(int x, int y) {
  if (L[x] < L[y]) x ^= y, y ^= x, x ^= y;
  int i;
  for (i = 19; i >= 0; --i)
    if (P[x][i] && L[P[x][i]] >= L[y]) x = P[x][i];
  if (x == y) return x;
  for (i = 19; i >= 0; --i)
    if (P[x][i] != P[y][i]) x = P[x][i], y = P[y][i];
  return P[x][0];
}
inline int dist(int x, int y) { return L[x] + L[y] - (L[LCA(x, y)] << 1); }
void solve() {
  int i, x = 2, y = 3, r = 2, m = 4;
  for (i = 1; i <= q; ++i, m += 2) {
    if (dist(x, m + 1) > r) {
      y = m + 1;
      ++r;
    } else if (dist(x, m + 2) > r) {
      y = m + 2;
      ++r;
    } else if (dist(y, m + 1) > r) {
      x = m + 1;
      ++r;
    } else if (dist(y, m + 2) > r) {
      x = m + 2;
      ++r;
    }
    cout << r << "\n";
  }
}
int main() {
  iostream::sync_with_stdio(false);
  cin.rdbuf()->pubsetbuf(Buffer, 32768);
  enter();
  init();
  solve();
  return 0;
}
