#include <bits/stdc++.h>
using namespace std;
const int logq = 19;
int main() {
  int q;
  scanf("%d", &q);
  vector<vector<int> > graf(q * 2 + 4, vector<int>());
  vector<vector<int> > lca(logq, vector<int>(q * 2 + 4, -1));
  vector<int> dub(q * 2 + 4);
  graf[1].push_back(0);
  graf[2].push_back(0);
  graf[3].push_back(0);
  lca[0][1] = lca[0][2] = lca[0][3] = 0;
  dub[0] = 0;
  dub[1] = dub[2] = dub[3] = 1;
  int a;
  vector<int> aovi(q);
  for (int qq = 0; qq < (q); qq++) {
    scanf("%d", &a);
    a--;
    aovi[qq] = a;
    graf[qq * 2 + 4].push_back(a);
    graf[qq * 2 + 5].push_back(a);
    lca[0][qq * 2 + 4] = lca[0][qq * 2 + 5] = a;
    dub[qq * 2 + 4] = dub[qq * 2 + 5] = dub[a] + 1;
  }
  for (int i = 1; i < logq; i++) {
    for (int j = 0; j < (q * 2 + 4); j++) {
      if (lca[i - 1][j] != -1) lca[i][j] = lca[i - 1][lca[i - 1][j]];
    }
  }
  int u = 1, v = 2, dij = 2;
  for (int tt = 0; tt < (q); tt++) {
    int tr = tt * 2 + 4;
    for (int nis = 0; nis < (2); nis++) {
      int dist = 0;
      int pa = u, pb = tr, raz, br = 0;
      if (dub[pa] < dub[pb]) swap(pa, pb);
      raz = dub[pa] - dub[pb];
      while (raz) {
        if (raz & 1) {
          pa = lca[br][pa];
          dist += (1 << br);
        }
        raz >>= 1;
        br++;
      }
      for (int i = logq - 1; i >= 0; i--) {
        if (lca[i][pa] != lca[i][pb]) {
          pa = lca[i][pa];
          pb = lca[i][pb];
          dist += 2 * (1 << i);
        }
      }
      if (pa != pb) dist += 2;
      if (dist > dij) {
        dij = dist;
        v = tr;
        break;
      }
      swap(u, v);
    }
    printf("%d\n", dij);
  }
  return 0;
}
