#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2 * 6 * 100000;
const int MAXL = 21;
int n;
int d[MAXN];
int p[MAXN][MAXL];
int lca(int u, int v) {
  if (d[u] > d[v]) {
    int dv = d[v];
    for (int i = MAXL - 1; i >= 0; i--) {
      if (d[p[u][i]] >= dv) {
        u = p[u][i];
      }
    }
  }
  if (d[v] > d[u]) {
    int du = d[u];
    for (int i = MAXL - 1; i >= 0; i--) {
      if (d[p[v][i]] >= du) {
        v = p[v][i];
      }
    }
  }
  if (u == v) return u;
  for (int i = MAXL - 1; i >= 0; i--) {
    if (p[u][i] != p[v][i]) {
      u = p[u][i];
      v = p[v][i];
    }
  }
  return p[u][0];
}
int dist(int u, int v) {
  int pred = lca(u, v);
  return d[u] + d[v] - 2 * d[pred];
}
int main() {
  n = 4;
  int q;
  scanf("%d", &q);
  d[1] = d[2] = d[3] = 1;
  int len = 2;
  int a = 1, b = 2;
  for (int it = 0; it < q; it++) {
    int v;
    scanf("%d", &v);
    v--;
    p[n][0] = v;
    for (int i = 1; i < MAXL; i++) {
      p[n][i] = p[p[n][i - 1]][i - 1];
    }
    for (int i = 0; i < MAXL; i++) {
      p[n + 1][i] = p[n][i];
    }
    d[n] = d[n + 1] = d[v] + 1;
    int dista = dist(n, a), distb = dist(n, b);
    if (dista >= distb && dista > len) {
      len = dista;
      b = n;
    } else if (distb > len) {
      len = distb;
      a = n;
    }
    printf("%d\n", len);
    n += 2;
  }
  return 0;
}
