#include <bits/stdc++.h>
using namespace std;
int read() {
  char s;
  int x = 0, f = 1;
  s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x *= 10;
    x += s - '0';
    s = getchar();
  }
  return x * f;
}
int p[1000050][30];
int dist[1000050];
int q;
int l, r, len = 2;
int n = 4;
int getlca(int a, int b) {
  if (dist[a] > dist[b]) swap(a, b);
  for (int i = 20; i >= 0; i--) {
    if (dist[p[b][i]] >= dist[a]) b = p[b][i];
    if (a == b) break;
  }
  if (a == b) return a;
  for (int i = 20; i >= 0; i--)
    if (p[a][i] != p[b][i]) a = p[a][i], b = p[b][i];
  return p[a][0];
}
int main() {
  q = read();
  p[2][0] = 1;
  p[3][0] = 1;
  p[4][0] = 1;
  dist[2] = dist[3] = dist[4] = 1;
  l = 2;
  r = 3;
  for (int i = 1; i <= q; i++) {
    int u;
    u = read();
    dist[n + 1] = dist[u] + 1;
    dist[n + 2] = dist[u] + 1;
    p[n + 1][0] = u;
    p[n + 2][0] = u;
    int k = log2(n + 2);
    for (int i = 1; i <= k; i++) {
      p[n + 1][i] = p[p[n + 1][i - 1]][i - 1];
      p[n + 2][i] = p[p[n + 2][i - 1]][i - 1];
    }
    int x = getlca(n + 1, l);
    int y = getlca(n + 2, r);
    int ans1 = dist[n + 1] + dist[l] - 2 * dist[x];
    int ans2 = dist[n + 2] + dist[r] - 2 * dist[y];
    if (ans1 > len) {
      len = ans1;
      r = n + 1;
    } else if (ans2 > len) {
      len = ans2;
      l = n + 2;
    }
    n += 2;
    printf("%d\n", len);
  }
}
