#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T x) {
  return x * x;
}
const int maxn = 10 * (int)1e5 + 5;
const int lim = 33;
int n;
pair<int, int> query[maxn];
int q;
vector<int> g[maxn];
void addEdge(int x, int y) {
  g[x].push_back(y);
  g[y].push_back(x);
}
int up[maxn][lim + 1], dep[maxn], tin[maxn], tout[maxn], timer;
void dfs(int v, int d, int p = 1) {
  up[v][0] = p;
  tin[v] = ++timer;
  for (int i = 1; i <= lim; ++i) up[v][i] = up[up[v][i - 1]][i - 1];
  dep[v] = d;
  for (int i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    if (to == p) continue;
    dfs(to, d + 1, v);
  }
  tout[v] = ++timer;
}
bool upper(int u, int v) { return tin[u] <= tin[v] && tout[u] >= tout[v]; }
int getLca(int x, int y) {
  if (upper(x, y)) return x;
  if (upper(y, x)) return y;
  for (int i = lim; i >= 0; --i)
    if (!upper(up[x][i], y)) x = up[x][i];
  return up[x][0];
}
int getdist(int x, int y) { return dep[x] + dep[y] - 2 * dep[getLca(x, y)]; }
int x = 2, y = 3, ans = 2;
int main() {
  srand(time(NULL));
  ios_base::sync_with_stdio(0);
  n = 4;
  addEdge(1, 2);
  addEdge(1, 3);
  addEdge(1, 4);
  cin >> q;
  for (int i = 1; i <= q; ++i) {
    int v;
    cin >> v;
    addEdge(v, n + 1);
    addEdge(v, n + 2);
    query[i].first = n + 1;
    query[i].second = n + 2;
    n += 2;
  }
  dfs(1, 0);
  for (int i = 1; i <= q; ++i) {
    int v = query[i].first;
    int d1 = getdist(x, v), d2 = getdist(v, y);
    if (d1 > d2) {
      if (d1 > ans) {
        ans = d1;
        x = x, y = v;
      }
    } else {
      if (d2 > ans) {
        ans = d2;
        x = v, y = y;
      }
    }
    v = query[i].second;
    d1 = getdist(x, v), d2 = getdist(v, y);
    if (d1 > d2) {
      if (d1 > ans) {
        ans = d1;
        x = x, y = v;
      }
    } else {
      if (d2 > ans) {
        ans = d2;
        x = v, y = y;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
