#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
const int LN = 20;
int parent[LN][N];
int depth[N];
int node1, node2;
int n, q, ans;
void pre() {
  node1 = 2;
  node2 = 4;
  n = 4;
  ans = 2;
  parent[0][2] = 1;
  parent[0][3] = 1;
  parent[0][4] = 1;
  depth[1] = 0;
  depth[2] = 1;
  depth[3] = 1;
  depth[4] = 1;
}
int LCA(int u, int v) {
  if (depth[u] < depth[v]) {
    return LCA(v, u);
  }
  int diff = depth[u] - depth[v];
  for (int i = 0; i < LN; ++i) {
    if ((diff >> i) & 1) {
      u = parent[i][u];
    }
  }
  if (u != v) {
    for (int i = LN - 1; i >= 0; --i) {
      if (parent[i][u] != parent[i][v]) {
        u = parent[i][u];
        v = parent[i][v];
      }
    }
    u = parent[0][u];
  }
  return u;
}
int dist(int a, int b) { return depth[a] + depth[b] - (depth[LCA(a, b)] << 1); }
int main() {
  pre();
  scanf(" %d ", &q);
  while (q--) {
    int node;
    scanf("%d", &node);
    parent[0][n + 1] = node;
    parent[0][n + 2] = node;
    for (int i = 1; i < LN; ++i) {
      parent[i][n + 1] = parent[i - 1][parent[i - 1][n + 1]];
      parent[i][n + 2] = parent[i][n + 1];
    }
    depth[n + 1] = depth[node] + 1;
    depth[n + 2] = depth[node] + 1;
    int d1 = dist(n + 1, node1);
    int d2 = dist(n + 2, node2);
    if (d1 > ans) {
      node2 = n + 1;
      ans = d1;
    }
    if (d2 > ans) {
      node1 = n + 2;
      ans = d2;
    }
    printf("%d\n", ans);
    n += 2;
  }
}
