#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10, MOD = 1e9 + 7;
int n, m, q, mxd = 2, l = 19, v1 = 2, v2 = 4;
vector<int> qrs, grf[MAXN];
int tin[MAXN], tout[MAXN], disfr[MAXN], timer = 1;
int par[MAXN][20];
void build(int node, int p = 1, int lvl = 0) {
  tin[node] = timer++;
  disfr[node] = lvl;
  par[node][0] = p;
  for (int i = 1; i <= l; i++) {
    par[node][i] = par[par[node][i - 1]][i - 1];
  }
  for (auto nbr : grf[node]) {
    if (nbr != p) {
      build(nbr, node, lvl + 1);
    }
  }
  tout[node] = timer++;
}
bool isanc(int u, int v) { return tin[u] <= tin[v] and tout[u] >= tout[v]; }
int lca(int u, int v) {
  if (isanc(u, v)) return u;
  if (isanc(v, u)) return v;
  for (int i = l; i >= 0; i--)
    if (!isanc(par[u][i], v)) {
      u = par[u][i];
    }
  return par[u][0];
}
int dist(int a, int b) { return disfr[a] + disfr[b] - 2 * disfr[lca(a, b)]; }
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  for (auto i : {2, 3, 4}) grf[1].push_back(i);
  cin >> q;
  int cur = 5, tmp;
  for (int i = 0; i < q; i++) {
    cin >> tmp;
    qrs.push_back(cur);
    grf[tmp].push_back(cur);
    grf[tmp].push_back(cur + 1);
    grf[cur].push_back(tmp);
    grf[cur + 1].push_back(tmp);
    cur += 2;
  }
  build(1);
  for (auto i : qrs) {
    int dis1 = dist(i, v1);
    int dis2 = dist(i, v2);
    if (dis1 > mxd) {
      mxd = dis1;
      v2 = i;
    }
    if (dis2 > mxd) {
      mxd = dis2;
      v1 = i;
    }
    cout << mxd;
    cout << "\n";
    ;
  }
}
