#include <bits/stdc++.h>
using namespace std;
int dep[1000010];
int f[1000010][20];
void add(int x, int fa) {
  dep[x] = dep[fa] + 1;
  f[x][0] = fa;
  for (int i = 1; i < 20; i++) f[x][i] = f[f[x][i - 1]][i - 1];
}
int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 0; i < 20; i++)
    if ((dep[x] - dep[y]) & (1 << i)) x = f[x][i];
  for (int i = 19; i >= 0; i--) {
    if (f[x][i] != f[y][i]) {
      x = f[x][i];
      y = f[y][i];
    }
  }
  return f[x][0];
}
int query(int x, int y) { return dep[x] + dep[y] - 2 * dep[lca(x, y)]; }
int main() {
  int n, i, j;
  while (scanf("%d", &n) != EOF) {
    int id = 4, p = 3, q = 4, ans = 2;
    dep[1] = 0;
    add(2, 1), add(3, 1), add(4, 1);
    while (n--) {
      int x;
      scanf("%d", &x);
      add(++id, x);
      add(++id, x);
      if (query(p, id) > ans) {
        ans++;
        q = id;
      } else if (query(q, id) > ans) {
        ans++;
        p = id;
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
