#include <bits/stdc++.h>
using namespace std;
int par[2000006][24];
int h[2000006];
vector<int> graph[2000006];
void dfs(int now, int from = -1) {
  par[now][0] = from;
  if (from + 1) {
    h[now] = h[from] + 1;
  }
  for (int i = 1; i < 24; i++) {
    if (par[now][i - 1] + 1) {
      par[now][i] = par[par[now][i - 1]][i - 1];
    }
  }
  for (auto to : graph[now]) {
    if (to != from) {
      dfs(to, now);
    }
  }
}
int parent(int x, int j) {
  for (int i = 0; i < 24; i++)
    if (j & (1 << i)) x = par[x][i];
  return x;
}
int LCA(int v, int u) {
  if (h[v] < h[u]) swap(v, u);
  for (int i = 24 - 1; i >= 0; i--) {
    if (par[v][i] + 1 && h[par[v][i]] >= h[u]) {
      v = par[v][i];
    }
  }
  if (u == v) return v;
  for (int i = 24 - 1; i >= 0; i--) {
    if (par[v][i] - par[u][i]) {
      v = par[v][i];
      u = par[u][i];
    }
  }
  return par[v][0];
}
int dist(int x, int y) { return h[x] + h[y] - 2 * h[LCA(x, y)]; }
int main() {
  int q, i, j;
  graph[1].push_back(2);
  graph[2].push_back(1);
  graph[1].push_back(3);
  graph[3].push_back(1);
  graph[1].push_back(4);
  graph[4].push_back(1);
  memset(par, -1, sizeof(par));
  dfs(1);
  int x = 2, y = 4, d = 2;
  int curr = 4;
  scanf("%d", &q);
  while (q--) {
    int v;
    scanf("%d", &v);
    ++curr;
    h[curr] = h[v] + 1;
    par[curr][0] = v;
    for (int i = 1; i < 24; i++) {
      if (par[curr][i - 1] + 1) {
        par[curr][i] = par[par[curr][i - 1]][i - 1];
      }
    }
    ++curr;
    h[curr] = h[v] + 1;
    par[curr][0] = v;
    for (int i = 1; i < 24; i++) {
      if (par[curr][i - 1] + 1) {
        par[curr][i] = par[par[curr][i - 1]][i - 1];
      }
    }
    if (x == v) {
      x = curr;
      d++;
    } else if (y == v) {
      y = curr;
      d++;
    } else {
      if (dist(x, curr) > d) {
        y = curr;
        d = dist(x, curr);
      } else {
        if (dist(y, curr) > d) {
          x = curr;
          d = dist(y, curr);
        }
      }
    }
    printf("%d\n", d);
  }
  return 0;
}
