#include <bits/stdc++.h>
using namespace std;
int const maxn = 1000100, maxk = 30;
int m, dp[maxk][maxn], prof[maxn];
vector<int> adj[maxn];
void dfs(int v) {
  for (auto i : adj[v])
    if (i != dp[0][v]) prof[i] = prof[v] + 1, dp[0][i] = v, dfs(i);
}
int lca(int x, int y) {
  if (prof[y] < prof[x]) swap(x, y);
  int dis = prof[y] - prof[x];
  for (int k = (int)maxk - 1; k >= 0; k--)
    if ((1 << k) & dis) y = dp[k][y];
  if (x == y) return x;
  for (int k = (int)maxk - 1; k >= 0; k--)
    if (dp[k][x] != dp[k][y]) x = dp[k][x], y = dp[k][y];
  return dp[0][y];
}
int dist(int x, int y) { return prof[x] + prof[y] - 2 * prof[lca(x, y)]; }
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> m;
  adj[1].push_back(2), adj[2].push_back(1);
  adj[1].push_back(3), adj[3].push_back(1);
  adj[1].push_back(4), adj[4].push_back(1);
  int cont = 4;
  for (int i = 1; i <= (int)m; i++) {
    int v;
    cin >> v;
    cont++;
    adj[cont].push_back(v);
    adj[v].push_back(cont);
    cont++;
    adj[cont].push_back(v);
    adj[v].push_back(cont);
  }
  dp[0][1] = 1;
  dfs(1);
  for (int k = 1; k <= (int)maxk - 1; k++)
    for (int i = 1; i <= (int)cont; i++) dp[k][i] = dp[k - 1][dp[k - 1][i]];
  int x = 2, y = 3, ans = 2;
  for (int i = (int)5; i <= (int)cont; i++) {
    int d1 = dist(x, i), d2 = dist(y, i);
    if (d1 > ans && d1 >= d2)
      ans = d1, y = i;
    else if (d2 > ans && d2 >= d1)
      ans = d2, x = i;
    i++;
    cout << ans << '\n';
  }
}
