#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 * 1000 + 12, maxlg = 26;
int q, g1, g2, ghotr, dis[maxn], n = 3, par[maxlg][maxn];
int getpar(int x, int k) {
  for (int i = maxlg - 1; i >= 0; i--)
    if ((k & (1 << i))) x = par[i][x];
  return x;
}
int lca(int x, int y) {
  if (dis[y] < dis[x]) swap(x, y);
  y = getpar(y, dis[y] - dis[x]);
  if (x == y) return y;
  for (int i = maxlg - 1; i >= 0; i--) {
    if (par[i][x] != par[i][y]) {
      x = par[i][x];
      y = par[i][y];
    }
  }
  return par[0][x];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  dis[0] = 0, dis[1] = 1, dis[2] = 1, dis[3] = 1, cin >> q;
  g1 = 1;
  g2 = 2;
  ghotr = 2;
  for (int i = 0; i < q; i++) {
    int x;
    cin >> x;
    x--;
    par[0][n + 1] = x;
    par[0][n + 2] = x;
    dis[n + 1] = dis[x] + 1;
    dis[n + 2] = dis[x] + 1;
    for (int j = 1; j < maxlg; j++) {
      par[j][n + 1] = par[j - 1][par[j - 1][n + 1]];
      par[j][n + 2] = par[j - 1][par[j - 1][n + 2]];
    }
    int p1 = lca(n + 1, g1);
    int p2 = lca(n + 1, g2);
    if (dis[n + 1] + dis[g1] - 2 * dis[p1] > ghotr) {
      g2 = n + 1;
      ghotr = dis[n + 1] + dis[g1] - 2 * dis[p1];
    } else if ((dis[n + 1] + dis[g2] - 2 * dis[p2] > ghotr)) {
      g1 = n + 1;
      ghotr = dis[n + 1] + dis[g2] - 2 * dis[p2];
    }
    n += 2;
    cout << ghotr << "\n";
  }
}
