#include <bits/stdc++.h>
using namespace std;
int a[1000 * 1000 + 4][18], g[1000 * 1000 + 4], q, k, n, i, m = 2, v = 1, x, y;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> q;
  g[1] = 1;
  g[2] = 1;
  g[3] = 1;
  n = 4;
  while (q--) {
    cin >> k;
    --k;
    a[n][0] = k;
    a[n + 1][0] = k;
    g[n] = g[k] + 1;
    g[n + 1] = g[k] + 1;
    for (int i = 1; i < 18; ++i) {
      a[n][i] = a[a[n][i - 1]][i - 1];
      a[n + 1][i] = a[a[n][i - 1]][i - 1];
    }
    if (g[n] > g[v]) {
      v = n;
      m++;
    } else if (g[n] + g[v] > m) {
      x = v;
      y = n;
      for (int i = 0; i < 18; ++i)
        if ((g[x] - g[y]) & (1 << i)) x = a[x][i];
      for (i = 17; i >= 0; --i)
        if (a[x][i] != a[y][i]) {
          x = a[x][i];
          y = a[y][i];
        }
      if (g[n] + g[v] - (g[a[x][0]] << 1) > m) m++;
    }
    n += 2;
    cout << m << "\n";
  }
  return 0;
}
