#include <bits/stdc++.h>
using namespace std;
int dis[1000005], far[20][1000005], v;
int n, m, a = 2, b = 3, r = 2;
int query(int a, int b) {
  if (dis[a] < dis[b]) swap(a, b);
  int d = dis[a] - dis[b];
  for (int i = 0; i < 20; i++)
    if (d & 1 << i) a = far[i][a];
  if (a == b) return a;
  for (int s = 20 - 1; s >= 0; s--)
    if (far[s][a] != far[s][b]) a = far[s][a], b = far[s][b];
  return far[0][a];
}
int main() {
  scanf("%d", &m);
  far[0][1] = far[0][2] = far[0][3] = far[0][4] = 1;
  dis[1] = 0;
  dis[2] = dis[3] = dis[4] = 1;
  n = 4;
  for (int i = 0; i < m; i++) {
    scanf("%d", &v);
    far[0][n + 1] = far[0][n + 2] = v;
    dis[n + 1] = dis[n + 2] = dis[v] + 1;
    n += 2;
  }
  for (int i = 1; i < 20; i++)
    for (int j = 1; j < n; j++) far[i][j] = far[i - 1][far[i - 1][j]];
  for (int i = 0; i < m; i++) {
    int c = 5 + i * 2;
    int x = query(c, a);
    int y = query(c, b);
    int dx = dis[a] + dis[c] - 2 * dis[x];
    int dy = dis[b] + dis[c] - 2 * dis[y];
    if (dx > dy && dx > r)
      r = dx, b = c;
    else if (dy > r)
      r = dy, a = c;
    printf("%d\n", r);
  }
}
