#include <bits/stdc++.h>
using namespace std;
const long double INF = 1LL << 60, EPS = 1LL >> 60;
int in() {
  char c;
  bool g = false;
  while (c = getchar(), c < '0' || c > '9')
    if (c == '-')
      g = true;
    else
      g = false;
  int x = 0;
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - 48;
    c = getchar();
  }
  return g ? -x : x;
}
void out(int x) {
  int len = 0, data[20];
  while (x) {
    data[len++] = x % 10;
    x /= 10;
  }
  if (!len) data[len++] = 0;
  if (data[0] != abs(data[0])) putchar('-');
  while (len--) putchar(abs(data[len]) + 48);
  putchar('\n');
}
void out(string s) {
  int len = 0;
  while (len++ < s.size()) putchar(s[len - 1]);
  putchar('\n');
}
const int LG = 20, N = 1000100;
int d[N], p[LG][N];
int lca(int u, int v) {
  if (d[u] > d[v]) swap(u, v);
  int dis = d[v] - d[u];
  for (int i = LG - 1; i >= 0; i--)
    if ((dis >> i) & 1) v = p[i][v];
  if (v == u) return v;
  for (int i = LG - 1; i >= 0; i--)
    if (p[i][v] != p[i][u]) v = p[i][v], u = p[i][u];
  return p[0][v];
}
int main() {
  int n = in(), k = 4;
  p[0][2] = p[0][3] = p[0][4] = 1;
  d[2] = d[3] = d[4] = 1;
  int ans = 2, ansv = 2, ansu = 3;
  while (n--) {
    int a = in();
    d[k + 1] = d[k + 2] = d[a] + 1;
    p[0][k + 1] = p[0][k + 2] = a;
    for (int i = 1; i < LG; i++) p[i][k + 1] = p[i - 1][p[i - 1][k + 1]];
    for (int i = 1; i < LG; i++) p[i][k + 2] = p[i - 1][p[i - 1][k + 2]];
    int d1 = d[ansv] + d[k + 1] - 2 * d[lca(ansv, k + 1)],
        d2 = d[ansu] + d[k + 1] - 2 * d[lca(ansu, k + 1)];
    if (d1 > ans) ans = d1, ansu = k + 1;
    if (d2 > ans) ans = d2, ansv = k + 1;
    k += 2;
    out(ans);
  }
  return 0;
}
