#include <bits/stdc++.h>
using namespace std;
int n, u, v;
int father[2000000];
int ud[2000000];
int p[2000000][21];
int CurD;
int lca(int, int);
int dis(int, int);
void AddTo(int);
int main() {
  n = 4;
  father[2] = father[3] = father[4] = 1;
  ud[1] = 0;
  ud[2] = ud[3] = ud[4] = 1;
  p[2][0] = p[3][0] = p[4][0] = 1;
  int q;
  cin >> q;
  u = 2;
  v = 3;
  CurD = 2;
  int ret;
  for (int i = 0; i < q; i++) {
    int x;
    fscanf(stdin, "%d", &x);
    AddTo(x);
    AddTo(x);
    fprintf(stdout, "%d\n", CurD);
  }
  return 0;
}
unsigned int getBit(unsigned int x, int i) { return ((x & (1 << i)) != 0); }
int lca(int i, int j) {
  if (ud[i] < ud[j]) swap(i, j);
  int t = ud[i] - ud[j];
  for (int bit = 0; (1 << bit) <= t; bit++)
    if (getBit(t, bit) == 1) {
      i = p[i][bit];
    }
  if (i == j) return i;
  int log = 0;
  while ((1 << log) <= ud[i]) log++;
  log--;
  for (int bit = log; bit >= 0; bit--)
    if (p[i][bit] != 0 && p[i][bit] != p[j][bit]) {
      i = p[i][bit];
      j = p[j][bit];
    }
  return father[i];
}
void AddTo(int x) {
  n++;
  father[n] = x;
  p[n][0] = x;
  ud[n] = ud[x] + 1;
  for (int j = 1; (1 << j) < n; j++) {
    p[n][j] = p[p[n][j - 1]][j - 1];
  }
  int ret = dis(n, u);
  if (CurD < ret) {
    CurD = ret;
    v = n;
  }
  ret = dis(n, v);
  if (CurD < ret) {
    CurD = ret;
    u = n;
  }
}
int dis(int i, int j) {
  int k = lca(i, j);
  return (ud[i] + ud[j] - 2 * ud[k]);
}
