#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
template <typename T>
struct rmq {
  vector<T> v;
  int n;
  static const int b = 30;
  vector<int> mask, t;
  inline int op(int x, int y) { return v[x] < v[y] ? x : y; }
  inline int msb(int x) {
    { return __builtin_clz(0) - __builtin_clz(x) - 1; }
  }
  rmq(const vector<T> &v_) : v(v_), n(v.size()), mask(n), t(2 * n) {
    for (int i = 0, at = 0; i < v.size(); mask[i++] = at |= 1) {
      at = (at << 1) & ((1 << b) - 1);
      while (at and op(i, i - msb(at & -at)) == i) at ^= at & -at;
    }
    for (int i = 0; i < n / b; i++)
      t[i] = b * i + b - 1 - msb(mask[b * i + b - 1]);
    for (int j = 1; (1 << j) <= n / b; j++)
      for (int i = 0; i + (1 << j) <= n / b; i++)
        t[n / b * j + i] =
            op(t[n / b * (j - 1) + i], t[n / b * (j - 1) + i + (1 << (j - 1))]);
  }
  inline int small(int r, int sz = b) {
    return r - msb(mask[r] & ((1 << sz) - 1));
  }
  T query(int l, int r) {
    if (r - l + 1 <= b) return small(r, r - l + 1);
    int ans = op(small(l + b - 1), small(r));
    int x = l / b + 1, y = r / b - 1;
    if (x <= y) {
      int j = msb(y - x + 1);
      ans = op(ans, op(t[n / b * j + x], t[n / b * j + y - (1 << j) + 1]));
    }
    return ans;
  }
  rmq() {}
};
const int MAX = 1e6 + 10;
vector<int> g[MAX];
int pos[MAX];
int ord[2 * MAX];
int v[2 * MAX];
int p, n;
rmq<int> rrr;
void dfs(int k, int l) {
  ord[p] = k;
  pos[k] = p;
  v[p++] = l;
  for (int i = 0; i < (int)g[k].size(); i++)
    if (pos[g[k][i]] == -1) {
      dfs(g[k][i], l + 1);
      ord[p] = k;
      v[p++] = l;
    }
}
void build(int root) {
  for (int i = 0; i < n; i++) pos[i] = -1;
  p = 0;
  dfs(root, 0);
  rrr = rmq<int>(vector<int>(&v[0], &v[2 * n]));
}
int lca(int u, int w) {
  int a = pos[u], b = pos[w];
  if (a > b) swap(a, b);
  int ans = ord[rrr.query(a, b)];
  return ans;
}
int dist(int u, int w) {
  int x = lca(u, w);
  int dist = v[pos[u]] + v[pos[w]] - 2 * v[pos[x]];
  return dist;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  g[1].push_back(2);
  g[1].push_back(3);
  g[1].push_back(4);
  n = 4;
  int q;
  cin >> q;
  vector<pair<int, int> > query(q);
  for (pair<int, int> &e : query) {
    int a = ++n, b = ++n;
    e = {a, b};
    int c;
    cin >> c;
    g[c].push_back(a);
    g[c].push_back(b);
  }
  build(1);
  int l = 2, r = 3, dim = 2;
  for (pair<int, int> &e : query) {
    int a, b;
    tie(a, b) = e;
    int dla = dist(l, a);
    int dra = dist(r, a);
    dim = max({dim, dla, dra});
    if (dim == dla)
      r = a;
    else if (dim == dra)
      l = a;
    cout << dim << '\n';
  }
  exit(0);
}
