#include <bits/stdc++.h>
using namespace std;
int anc[1000100][21], depth[1000100];
int ancestor(int x, int k) {
  int p = 0;
  while (k) {
    if (k & 1) x = anc[x][p];
    ++p;
    k >>= 1;
  }
  return x;
}
int LCAdepth(int x, int y) {
  int left = 1, right = min(depth[x], depth[y]);
  while (left <= right) {
    int mid = (left + right) / 2;
    if (ancestor(x, depth[x] - mid) == ancestor(y, depth[y] - mid)) {
      left = mid + 1;
    } else {
      right = mid - 1;
    }
  }
  return right;
}
int main() {
  int n = 4, x, px = 2, py = 3, m, diameter = 2;
  scanf("%d", &m);
  anc[2][0] = anc[3][0] = anc[4][0] = 1;
  depth[1] = 1;
  depth[2] = depth[3] = depth[4] = 2;
  while (m--) {
    scanf("%d", &x);
    depth[n + 1] = depth[n + 2] = depth[x] + 1;
    for (int i = 0; (1 << i) <= depth[x]; ++i) {
      anc[n + 1][i] = anc[n + 2][i] = ancestor(x, (1 << i) - 1);
    }
    int lcad;
    lcad = LCAdepth(px, n + 1);
    if (depth[px] + depth[n + 1] - 2 * lcad > diameter) {
      diameter = depth[px] + depth[n + 1] - 2 * lcad;
      py = n + 1;
    }
    lcad = LCAdepth(py, n + 1);
    if (depth[py] + depth[n + 1] - 2 * lcad > diameter) {
      diameter = depth[py] + depth[n + 1] - 2 * lcad;
      px = n + 1;
    }
    n += 2;
    printf("%d\n", diameter);
  }
}
