#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:10000000000")
#pragma GCC optimize("Ofast")
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000007LL;
const long long INF2 = 1000000007LL * 1000000007LL;
const long double EPS = 1e-4 / 2;
const int SIZE = 1001000;
mt19937 rng(time(0));
uniform_int_distribution<int> uid(-1000000000, 1000000000);
vector<int> g[SIZE], p[SIZE];
int n, len, level[SIZE];
void init(int v, int parent = -1, int lvl = 0) {
  p[v].resize(len, -1);
  p[v][0] = parent;
  level[v] = lvl;
  for (int i = 1; i < len && p[v][i - 1] != -1; ++i) {
    p[v][i] = p[p[v][i - 1]][i - 1];
  }
  for (auto& i : g[v]) {
    if (i == parent) continue;
    init(i, v, lvl + 1);
  }
}
int la(int a, int dist) {
  if (dist == 0) return a;
  if (level[a] - dist < 0) return -1;
  int levelA = level[a] - dist;
  for (int i = len - 1; i >= 0; --i) {
    if (p[a][i] != -1 && level[p[a][i]] > levelA) a = p[a][i];
  }
  a = p[a][0];
  return a;
}
int lca_online(int a, int b) {
  if (level[b] < level[a]) swap(a, b);
  if (level[b] > level[a]) b = la(b, level[b] - level[a]);
  if (a == b) return a;
  for (int i = len - 1; i >= 0; --i) {
    if (p[a][i] != p[b][i]) {
      a = p[a][i];
      b = p[b][i];
    }
  }
  a = p[a][0];
  return a;
}
int dist(int a, int b) {
  int c = lca_online(a, b);
  return level[a] - level[c] + level[b] - level[c];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  while ((1 << len) <= SIZE) ++len;
  int n = 4, q;
  cin >> q;
  init(0);
  for (int i = 1; i < n; ++i) {
    g[0].push_back(i);
    init(i, 0, level[0] + 1);
  }
  int x = 1, y = 2, z;
  for (int rep_iter = 0; rep_iter < q; ++rep_iter) {
    cin >> z;
    --z;
    g[z].push_back(n);
    init(n, z, level[z] + 1);
    g[z].push_back(n + 1);
    init(n + 1, z, level[z] + 1);
    z = n;
    n += 2;
    if (dist(z, x) > dist(x, y)) y = z;
    if (dist(z, y) > dist(x, y)) x = z;
    cout << dist(x, y) << '\n';
  }
  return 0;
}
