#include <bits/stdc++.h>
using namespace std;
inline bool iseq(double x, double y) {
  if (fabs(x - y) < 1e-8) return true;
  return false;
}
template <typename T>
inline T hpt(T x1, T y1, T x2, T y2) {
  return hypot(x1 - x2, y1 - y2);
}
template <typename T>
inline T gcd(T a, T b) {
  if (!b)
    return a;
  else
    return gcd(b, a % b);
}
template <typename T>
inline void extended_euclid(T a, T b, T &x, T &y) {
  if (a % b == 0)
    x = 0, y = 1;
  else {
    extended_euclid(b, a % b, x, y);
    T temp = x;
    x = y;
    y = -y * (a / b) + temp;
  }
}
template <typename T>
inline T bigmod(T b, T p, T m) {
  if (!p)
    return 1;
  else if (!(p % 2)) {
    T x = bigmod(b, p / 2, m);
    return (x * x) % m;
  } else
    return ((b % m) * bigmod(b, p - 1, m)) % m;
}
int prime[5 / 32 + 1];
void setbit(int i) {
  int p = i >> 5, q = i & 31;
  prime[p] |= (1 << q);
}
bool checkbit(int i) {
  int p = i >> 5, q = i & 31;
  return prime[p] & (1 << q) ? true : false;
}
void buildprime(int n) {
  int i, j, k = sqrt(double(n));
  prime[0] = 3;
  for (i = 4; i < n; i += 2) setbit(i);
  for (i = 3; i <= k; i += 2) {
    if (!checkbit(i)) {
      int ii = i + i;
      for (j = i * i; j < n; j += ii) setbit(j);
    }
  }
}
int sum, r, n, N, R, C;
int level[1000050], pa[1000050], T[1000050][22];
int LCA(int a, int b, int tot) {
  if (level[a] > level[b]) swap(a, b);
  int log;
  for (log = 0; 1 << log < tot; ++log)
    ;
  --log;
  for (int i = log; i >= 0; --i) {
    if (level[b] - (1 << i) >= level[a]) b = T[b][i];
  }
  if (a == b) return a;
  for (int i = log; i >= 0; --i) {
    if (T[a][i] != -1 && T[b][i] != -1 && T[a][i] != T[b][i]) {
      a = T[a][i];
      b = T[b][i];
    }
  }
  return pa[a];
}
int calcLCA(int a, int b, int tot) {
  int parent = LCA(a, b, tot);
  return level[a] + level[b] - 2 * level[parent];
}
int main() {
  int i, j, k;
  while (scanf("%d", &n) == 1) {
    level[1] = 1;
    pa[1] = -1;
    level[2] = level[3] = level[4] = 2;
    pa[2] = pa[3] = pa[4] = 1;
    memset(T, -1, sizeof T);
    T[2][0] = T[3][0] = T[4][0] = 1;
    int a = 2, b = 4, diff = 2;
    int v1 = 5, v2 = 6;
    for ((i) = (0); (i) < (n); (i)++) {
      scanf("%d", &k);
      level[v1] = level[v2] = level[k] + 1;
      pa[v1] = pa[v2] = k;
      T[v1][0] = T[v2][0] = k;
      for (int i = 1;; ++i) {
        int parent = T[v1][i - 1];
        if (T[parent][i - 1] == -1) break;
        T[v1][i] = T[v2][i] = T[parent][i - 1];
      }
      if (k == a || k == b) {
        diff++;
        if (k == a)
          a = v1;
        else
          b = v2;
        cout << diff << endl;
      } else {
        int d1 = calcLCA(a, k, v1 - 1);
        int d2 = calcLCA(b, k, v1 - 1);
        if (diff == d1 || diff == d2) {
          if (diff == d1)
            b = v2;
          else
            a = v1;
          diff++;
        }
        cout << diff << endl;
      }
      v1 += 2;
      v2 += 2;
    }
  }
  return 0;
}
