#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
const long long linf = 1e18 + 5;
const int N = 5e5 * 2 + 5;
const int LOG = 20;
int n, x, lca[LOG][N], dep[N], cur, mx, mx2, lp, ans, ans2;
int get(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = LOG - 1; i >= 0; i--)
    if (dep[lca[i][x]] >= dep[y]) x = lca[i][x];
  if (x == y) return x;
  for (int i = LOG - 1; i >= 0; i--)
    if (lca[i][x] != lca[i][y]) {
      x = lca[i][x];
      y = lca[i][y];
    }
  return lca[0][x];
}
int main() {
  dep[1] = 1;
  for (int i = 2; i <= 4; i++) {
    lca[0][i] = 1;
    dep[i] = 2;
  }
  mx = 2;
  mx2 = 3;
  lp = 2;
  cur = 4;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    cur++;
    dep[cur] = dep[x] + 1;
    lca[0][cur] = x;
    for (int i = 1; i <= LOG - 1; i++)
      lca[i][cur] = lca[i - 1][lca[i - 1][cur]];
    cur++;
    dep[cur] = dep[x] + 1;
    lca[0][cur] = x;
    for (int i = 1; i <= LOG - 1; i++)
      lca[i][cur] = lca[i - 1][lca[i - 1][cur]];
    ans = dep[mx] + dep[cur] - dep[get(mx, cur)] * 2;
    ans2 = dep[mx2] + dep[cur] - dep[get(mx2, cur)] * 2;
    if (ans > lp and ans >= ans2) {
      lp = ans;
      mx2 = cur;
    } else if (ans2 > lp) {
      lp = ans2;
      mx = cur;
    }
    printf("%d\n", lp);
  }
  0;
  return 0;
}
