#include <bits/stdc++.h>
using namespace std;
const double eps = 1.0e-11;
const double pi = acos(-1.0);
const int N = 1000100;
vector<vector<int> > g;
int depth[N], in[N], out[N], p[N][22];
int timer, l;
void dfs(int v, int pp, int d) {
  depth[v] = d;
  in[v] = timer++;
  p[v][0] = pp;
  for (long long i = 1; i <= l; i++) p[v][i] = p[p[v][i - 1]][i - 1];
  for (long long i = 0; i < (int)(g[v]).size(); i++) {
    dfs(g[v][i], v, d + 1);
  }
  out[v] = timer++;
}
bool pred(int v, int u) { return (in[v] <= in[u] && out[v] >= out[u]); }
int lca(int v, int u) {
  if (pred(v, u)) return v;
  if (pred(u, v)) return u;
  for (long long i = l + 1 - 1; i >= 0; --i) {
    if (!pred(p[v][i], u)) v = p[v][i];
  }
  return p[v][0];
}
int get(int v, int u) {
  int l = lca(v, u);
  return depth[v] + depth[u] - 2 * depth[l];
}
int main() {
  int q;
  scanf("%d", &q);
  g.resize(2 * q + 4);
  g[0].push_back(1);
  g[0].push_back(2);
  g[0].push_back(3);
  int n = 4;
  for (long long query = 0; query < q; query++) {
    int v;
    scanf("%d", &v);
    --v;
    g[v].push_back(n);
    g[v].push_back(n + 1);
    n += 2;
  }
  while ((1 << l) <= n) ++l;
  dfs(0, 0, 0);
  int left = 1, right = 2, curr = 2;
  for (long long query = 0; query < q; query++) {
    int n1 = 4 + query * 2;
    int dd = get(left, n1);
    if (dd > curr) {
      curr = dd;
      right = n1;
    }
    dd = get(right, n1);
    if (dd > curr) {
      curr = dd;
      left = n1;
    }
    printf("%d\n", curr);
  }
  return 0;
}
