#include <bits/stdc++.h>
using namespace std;
const int inf = 1e15;
const int max_n = 1e6 + 10, log_n = 21;
int n;
int deep[max_n], p[max_n][log_n];
int sz = 5;
int v = 2, res = 2, max_deep = 1;
inline int lca(int a, int b) {
  int v1 = a, v2 = b;
  if (deep[a] < deep[b]) swap(a, b);
  for (int i = log_n - 1; i >= 0; i--) {
    if (deep[a] - (1 << i) >= deep[b]) {
      a = p[a][i];
    }
  }
  for (int i = log_n - 1; i >= 0; i--) {
    if (p[a][i] != p[b][i]) {
      a = p[a][i];
      b = p[b][i];
    }
  }
  if (a != b) a = p[a][0];
  return deep[v1] + deep[v2] - 2 * deep[a];
}
inline void add(int x, int y) {
  deep[y] = deep[x] + 1;
  p[y][0] = x;
  for (int i = 1; i < log_n; i++) p[y][i] = p[p[y][i - 1]][i - 1];
  if (deep[y] > max_deep) {
    max_deep++;
    v = y;
    res++;
  } else {
    res = max(res, lca(v, y));
  }
}
inline void solve() {
  cin >> n;
  add(1, 2);
  add(1, 3);
  add(1, 4);
  for (int i = 0; i < n; i++) {
    int x, y = sz++, z = sz++;
    cin >> x;
    add(x, y);
    add(x, z);
    cout << res << endl;
  }
}
signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  solve();
}
