#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int L = 20;
int h[N], par[N][L];
int getLca(int u, int v) {
  if (h[v] < h[u]) swap(u, v);
  int k = h[v] - h[u];
  for (int i = 0; i < L; i++)
    if (k >> i & 1) v = par[v][i];
  if (u == v) return v;
  for (int i = L - 1; i >= 0; i--)
    if (par[u][i] != par[v][i]) u = par[u][i], v = par[v][i];
  return par[u][0];
}
int dis(int u, int v) { return h[u] + h[v] - 2 * h[getLca(u, v)]; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n = 5, mx = 2, ans = 2;
  for (int i = 2; i <= 4; i++) h[i] = par[i][0] = 1;
  int q;
  cin >> q;
  while (q--) {
    int v;
    cin >> v;
    h[n] = h[v] + 1;
    par[n][0] = v;
    for (int i = 1; i < L; i++) par[n][i] = par[par[n][i - 1]][i - 1];
    n++;
    h[n] = h[v] + 1;
    par[n][0] = v;
    for (int i = 1; i < L; i++) par[n][i] = par[par[n][i - 1]][i - 1];
    if (h[v] == h[mx]) mx = n, ans++;
    ans = max(ans, dis(n, mx));
    n++;
    cout << ans << '\n';
  }
  return 0;
}
