#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int LOG = 20;
int n, t, x, y, m, tmp, sum, s1, s2, d, node;
int a[N], h[N], lca[N][LOG];
void ready() {
  d = 2, s1 = 2, s2 = 3, node = 4;
  for (int i = 2; i <= 4; i++) {
    h[i] = 1;
    lca[i][0] = 1;
  }
}
int up(int u, int dis) {
  for (int i = 0; i < LOG; i++) {
    if (((1 << i) & dis) == (1 << i)) {
      u = lca[u][i];
    }
  }
  return u;
}
int LCA(int u, int v) {
  if (h[v] > h[u]) {
    swap(v, u);
  }
  int dis = h[u] - h[v];
  u = up(u, dis);
  if (u == v) {
    return v;
  }
  for (int i = LOG - 1; i >= 0; i--) {
    if (lca[v][i] != lca[u][i]) {
      u = lca[u][i];
      v = lca[v][i];
    }
  }
  return lca[v][0];
}
int DIS(int u, int v) { return h[u] + h[v] - 2 * h[LCA(u, v)]; }
void solve(int n) {
  int v = node + 1;
  int u = node + 2;
  h[u] = h[n] + 1;
  h[v] = h[n] + 1;
  lca[v][0] = n;
  lca[u][0] = n;
  for (int i = 1; i < LOG; i++) {
    lca[v][i] = lca[lca[v][i - 1]][i - 1];
    lca[u][i] = lca[lca[u][i - 1]][i - 1];
  }
  if (DIS(u, s1) > d) {
    s2 = v;
    d++;
  }
  if (DIS(u, s2) > d) {
    s1 = v;
    d++;
  }
  node += 2;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ready();
  cin >> t;
  while (t--) {
    cin >> n;
    solve(n);
    cout << d << '\n';
  }
  return 0;
}
