#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 1e2;
int q, n, d, head, tail, depth[maxn], par[30][maxn];
vector<int> child[maxn];
inline void prepare(int u) {
  for (int i = 1; i < 30; i++)
    if (par[i - 1][u] != -1) par[i][u] = par[i - 1][par[i - 1][u]];
}
inline void addedge(int v, int u) {
  child[v].push_back(u);
  depth[u] = depth[v] + 1;
  par[0][u] = v;
  prepare(u);
}
inline int LCA(int v, int u) {
  if (depth[u] < depth[v]) swap(u, v);
  for (int i = 29; i >= 0; i--)
    if (depth[v] + (1 << i) <= depth[u]) u = par[i][u];
  if (u == v) return v;
  for (int i = 29; i >= 0; i--)
    if (par[i][u] != par[i][v]) {
      u = par[i][u];
      v = par[i][v];
    }
  return par[0][u];
}
int main() {
  par[0][0] = -1;
  depth[0] = 0;
  addedge(0, 1);
  addedge(0, 2);
  addedge(0, 3);
  n = 4;
  d = 2;
  head = 2, tail = 3;
  cin >> q;
  for (int v, i = 0; i < q; i++) {
    cin >> v;
    v--;
    addedge(v, n++);
    addedge(v, n++);
    int dis1 = depth[n - 1] + depth[head] - 2 * depth[LCA(n - 1, head)];
    int dis2 = depth[n - 1] + depth[tail] - 2 * depth[LCA(n - 1, tail)];
    if (dis2 > dis1) {
      swap(dis1, dis2);
      swap(head, tail);
    }
    if (dis1 > d) {
      tail = n - 1;
      d = dis1;
    }
    cout << d << endl;
  }
}
