#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 100;
int par[25][maxn];
int h[maxn];
int find_par(int v, int k) {
  for (int i = 0; i < 21; i++) {
    if ((k >> i) & 1) {
      v = par[i][v];
    }
  }
  return v;
}
int lca(int v, int u) {
  if (h[v] > h[u]) {
    swap(v, u);
  }
  u = find_par(u, h[u] - h[v]);
  if (v == u) {
    return v;
  }
  for (int i = 20; i >= 0; i--) {
    if (par[i][v] != par[i][u]) {
      v = par[i][v];
      u = par[i][u];
    }
  }
  return par[0][v];
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int q;
  cin >> q;
  h[2] = 1;
  h[3] = 1;
  h[4] = 1;
  par[0][2] = 1;
  par[0][3] = 1;
  par[0][4] = 1;
  int v = 2, u = 3, ans = 2;
  int n = 5;
  while (q > 0) {
    int w;
    cin >> w;
    par[0][n] = w;
    par[0][n + 1] = w;
    h[n] = h[n + 1] = h[w] + 1;
    for (int i = 1; i < 21; i++) {
      par[i][n] = par[i - 1][par[i - 1][n]];
      par[i][n + 1] = par[i - 1][par[i - 1][n + 1]];
    }
    int x = lca(n, v);
    int y = lca(n, u);
    int gh1 = (h[n] - h[x]) + (h[v] - h[x]);
    int gh2 = (h[n] - h[y]) + (h[u] - h[y]);
    if (gh1 > gh2) {
      if (gh1 > ans) {
        ans = gh1;
        u = n;
      }
    } else {
      if (gh2 > ans) {
        ans = gh2;
        v = n;
      }
    }
    n += 2;
    cout << ans << endl;
    q--;
  }
  return 0;
}
