#include <bits/stdc++.h>
using namespace std;
const int ms = 5e6;
int st[ms + ms], code[ms], n;
vector<int> qries, aux, adj[ms];
void build() {
  n = aux.size();
  for (int i = 0; i < (int)n; ++i) st[n + i] = aux[i];
  for (int i = n - 1; i > 0; --i) st[i] = min(st[i << 1], st[i << 1 | 1]);
}
int qry(int l, int r) {
  int res = 1e9;
  for (; l < r; l >>= 1, r >>= 1) {
    if (l & 1) res = min(res, st[l++]);
    if (r & 1) res = min(res, st[--r]);
  }
  return res;
}
void dfs(int u, int p, int d) {
  code[u] = aux.size();
  aux.push_back(d);
  for (auto v : adj[u]) {
    if (v != p) {
      dfs(v, u, d + 1);
      aux.push_back(d);
    }
  }
}
int dist(int u, int v) {
  int l = code[u] + n;
  int r = code[v] + n;
  if (l > r) swap(l, r);
  return st[l] + st[r] - 2 * qry(l, r + 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  for (int i = 2; i < (int)5; ++i) {
    adj[1].push_back(i);
    adj[i].push_back(1);
  }
  int q;
  cin >> q;
  int qtd = 5;
  for (int i = 0; i < (int)q; ++i) {
    int a;
    cin >> a;
    qries.push_back(a);
    adj[a].push_back(qtd);
    adj[qtd].push_back(a);
    ++qtd;
    adj[a].push_back(qtd);
    adj[qtd].push_back(a);
    ++qtd;
  }
  dfs(1, -1, 0);
  build();
  int x = 2, y = 3;
  int diam = 1;
  int i = 5;
  for (int i = 5; i < (int)q + q + 5; ++i) {
    int d = dist(x, i);
    if (d > diam) {
      diam = d;
      y = i;
    }
    d = dist(y, i);
    if (d > diam) {
      diam = d;
      x = i;
    }
    if (i % 2 == 0) cout << diam << '\n';
  }
  return 0;
}
