#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
ostream& operator<<(ostream& out, pair<T1, T2> p) {
  out << p.first << ' ' << p.second;
  return out;
}
template <class T1, class T2>
istream& operator>>(istream& in, pair<T1, T2>& p) {
  in >> p.first >> p.second;
  return in;
}
template <class T>
istream& operator>>(istream& in, vector<T>& v) {
  for (auto& x : v) in >> x;
  return in;
}
template <class T>
ostream& operator<<(ostream& out, vector<vector<T>>& v) {
  for (auto& x : v) out << x << '\n';
  return out;
}
template <class T>
ostream& operator<<(ostream& out, vector<T>& v) {
  for (auto x : v) out << x << ' ';
  return out;
}
const long long N = 1000005;
vector<long long> g[N];
long long p[N];
long long b_p[N][24];
long long level[N];
void dfs(long long u, long long e, long long l) {
  p[u] = e;
  level[u] = l;
  for (auto i : g[u]) {
    if (i != e) {
      dfs(i, u, l + 1);
    }
  }
}
void lift(long long n) {
  for (long long i = 0; i <= 23; i++) {
    for (long long j = 1; j <= n; j++) {
      if (i == 0)
        b_p[j][i] = p[j];
      else
        b_p[j][i] = b_p[b_p[j][i - 1]][i - 1];
    }
  }
}
long long lca(long long u, long long v) {
  if (level[v] < level[u]) u = v + u - (v = u);
  long long diff = level[u] - level[v];
  for (long long i = 23; i >= 0; i--) {
    if (level[v] - level[u] >= (1 << i)) {
      v = b_p[v][i];
    }
  }
  if (v == u) {
    return u;
  }
  long long k = ceil(log2(level[u]));
  while (k >= 0) {
    if (b_p[u][k] != b_p[v][k]) {
      u = b_p[u][k];
      v = b_p[v][k];
    }
    k--;
  }
  return p[u];
}
long long d(long long u, long long v) {
  return level[u] + level[v] - 2 * level[lca(u, v)];
}
void solve() {
  long long n;
  cin >> n;
  g[1].push_back(2);
  g[2].push_back(1);
  g[1].push_back(3);
  g[3].push_back(1);
  g[4].push_back(1);
  g[1].push_back(4);
  dfs(1, 1, 0);
  lift(4);
  long long v1 = 2;
  long long v2 = 3;
  long long cnt = 4;
  long long cur = 2;
  for (long long i = 0; i < n; i++) {
    long long v;
    cin >> v;
    long long new_node = ++cnt;
    long long new_node2 = ++cnt;
    level[new_node] = level[v] + 1;
    level[new_node2] = level[v] + 1;
    p[new_node] = v;
    p[new_node2] = v;
    for (long long i = 0; i <= 23; i++) {
      if (i == 0)
        b_p[new_node][i] = p[new_node];
      else
        b_p[new_node][i] = b_p[b_p[new_node][i - 1]][i - 1];
    }
    for (long long i = 0; i <= 23; i++) {
      if (i == 0)
        b_p[new_node2][i] = p[new_node2];
      else
        b_p[new_node2][i] = b_p[b_p[new_node2][i - 1]][i - 1];
    }
    long long cur1 = d(new_node, v1);
    long long cur2 = d(new_node, v2);
    if (max(cur1, cur2) > cur) {
      cur = max(cur1, cur2);
      if (cur1 > cur2)
        v2 = new_node;
      else
        v1 = new_node;
    }
    cout << cur << '\n';
  }
}
signed main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0), cerr.tie(0);
  ;
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
