#include <bits/stdc++.h>
using namespace std;
vector<int> G[1000100];
int tin[1000100], tout[1000100];
int h[1000100];
int n;
int T = 0;
int jumps[1000100][22 + 1];
void dfs(int v) {
  tin[v] = T++;
  for (int i = 0; i < G[v].size(); i++) {
    h[G[v][i]] = h[v] + 1;
    dfs(G[v][i]);
    jumps[G[v][i]][0] = v;
  }
  tout[v] = T++;
}
bool anc(int u, int v) { return tin[u] <= tin[v] && tout[v] <= tout[u]; }
int jump(int v, int c) {
  if (jumps[v][c] != -1)
    return jumps[v][c];
  else
    return jumps[v][c] = jump(jump(v, c - 1), c - 1);
}
int lca(int u, int v) {
  int cc = 22;
  while (cc >= 0) {
    if (!anc(jump(u, cc), v)) u = jump(u, cc);
    cc--;
  }
  while (!anc(u, v)) u = jump(u, 0);
  return u;
}
int dist(int u, int v) { return h[u] + h[v] - 2 * h[lca(u, v)]; }
int created[1000100];
int main() {
  ios_base::sync_with_stdio(false);
  n = 4;
  jumps[0][0] = 0;
  G[0].push_back(1);
  G[0].push_back(2);
  G[0].push_back(3);
  memset(jumps, -1, sizeof jumps);
  memset(h, 0, sizeof h);
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int v;
    cin >> v;
    created[i] = n;
    G[v - 1].push_back(n++);
    G[v - 1].push_back(n++);
  }
  dfs(0);
  int center1 = 0, center2 = 0, diam = 2;
  for (int ii = 0; ii < q; ii++) {
    assert(anc(center1, center2));
    if (center1 != center2) {
      if (dist(created[ii], center1) > diam / 2 && !anc(center2, created[ii])) {
        center2 = center1;
        diam++;
      } else if (dist(created[ii], center2) > diam / 2 &&
                 anc(center2, created[ii])) {
        center1 = center2;
        diam++;
      }
    } else {
      if (dist(center1, created[ii]) > diam / 2) {
        diam++;
        if (anc(center1, created[ii])) {
          for (int i = 0; i < G[center1].size(); i++)
            if (anc(G[center1][i], created[ii])) center2 = G[center1][i];
        } else {
          center2 = center1;
          center1 = jump(center1, 0);
        }
      }
    }
    cout << diam << "\n";
  }
}
