#include <bits/stdc++.h>
using namespace std;
int q;
int dis[1000008];
int up[1000008][23];
int deepth[1000008];
int lca(int a, int b) {
  if (deepth[a] < deepth[b]) {
    swap(a, b);
  }
  int f = deepth[a] - deepth[b];
  int base = 0;
  while (f) {
    if (f & 1) {
      a = up[a][base];
    }
    base++;
    f = f >> 1;
  }
  if (a != b) {
    for (int i = 22; i >= 0; i--) {
      if (up[a][i] != up[b][i]) {
        a = up[a][i];
        b = up[b][i];
      }
    }
    a = up[a][0];
  }
  return a;
}
int main() {
  int s = 2;
  int u = 4;
  int n = 4;
  int d = 2;
  memset(up, 0, sizeof(up));
  up[2][0] = 1;
  up[3][0] = 1;
  up[4][0] = 1;
  deepth[1] = 1;
  deepth[2] = 2;
  deepth[3] = 2;
  deepth[4] = 2;
  int q;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int a;
    scanf("%d", &a);
    up[n + 1][0] = a;
    up[n + 2][0] = a;
    deepth[n + 1] = deepth[a] + 1;
    deepth[n + 2] = deepth[a] + 1;
    for (int i = 1; i <= 22; i++) {
      up[n + 1][i] = up[up[n + 1][i - 1]][i - 1];
      up[n + 2][i] = up[up[n + 2][i - 1]][i - 1];
    }
    int LCA = lca(n + 1, s);
    int val = deepth[n + 1] - deepth[LCA] + deepth[s] - deepth[LCA];
    if (val > d) {
      u = n + 1;
      d = val;
    } else {
      int LCA2 = lca(n + 1, u);
      int val2 = deepth[n + 1] - deepth[LCA2] + deepth[u] - deepth[LCA2];
      if (val2 > d) {
        s = n + 1;
        d = val2;
      }
    }
    n += 2;
    printf("%d\n", d);
  }
  return 0;
}
