#include <bits/stdc++.h>
using namespace std;
const int maxn = 1111111;
int fa[maxn][22], dep[maxn];
void gao(int s, int f) {
  dep[s] = dep[f] + 1;
  fa[s][0] = f;
  for (int i = 1; i < 22; i++) {
    fa[s][i] = fa[fa[s][i - 1]][i - 1];
  }
}
int lca(int a, int b) {
  if (dep[a] < dep[b]) swap(a, b);
  int d = dep[a] - dep[b];
  for (int i = 21; i >= 0; i--) {
    if (d & (1 << i)) a = fa[a][i];
  }
  if (a == b) return a;
  for (int i = 21; i >= 0; i--) {
    if (fa[a][i] != fa[b][i]) {
      a = fa[a][i];
      b = fa[b][i];
    }
  }
  return fa[a][0];
}
int dist(int a, int b) { return dep[a] + dep[b] - 2 * dep[lca(a, b)]; }
int main() {
  ios_base::sync_with_stdio(false);
  int q;
  while (cin >> q) {
    dep[0] = 0;
    gao(1, 0);
    for (int i = 2; i < 5; i++) gao(i, 1);
    int n = 4, w;
    int r1 = 2, r2 = 3, ma = 2;
    while (q--) {
      cin >> w;
      gao(n + 1, w);
      gao(n + 2, w);
      int l1 = dist(r1, n + 1), l2 = dist(r2, n + 1);
      int lm = max(l1, l2);
      if (lm > ma) {
        if (l1 > l2) {
          r2 = n + 1;
        } else
          r1 = n + 1;
        ma = lm;
      }
      cout << ma << endl;
      n += 2;
    }
  }
  return 0;
}
