#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const double EPS = 1e-6;
int parent[1000010][19];
int depth[1000010];
int main() {
  int q;
  scanf("%d", &q);
  depth[2] = depth[3] = depth[4] = 1;
  parent[1][0] = parent[2][0] = parent[3][0] = parent[4][0] = 1;
  int n = 4;
  int diameter = 2;
  int a = 2, b = 3;
  while (q--) {
    int v;
    scanf("%d", &v);
    depth[n + 1] = depth[n + 2] = depth[v] + 1;
    parent[n + 1][0] = parent[n + 2][0] = v;
    for (int d = 1; d < 19; d++)
      parent[n + 1][d] = parent[n + 2][d] = parent[parent[n + 1][d - 1]][d - 1];
    if (depth[n + 1] > depth[a])
      a = n + 1, diameter++;
    else if (depth[n + 1] + depth[a] > diameter) {
      int x = a, y = n + 1;
      for (int d = 0; d < 19; d++)
        if ((depth[x] - depth[y]) >> d & 1) x = parent[x][d];
      for (int d = 19 - 1; d >= 0; d--)
        if (parent[x][d] != parent[y][d]) x = parent[x][d], y = parent[y][d];
      int LCA = parent[x][0];
      if (depth[n + 1] + depth[a] - depth[LCA] - depth[LCA] > diameter)
        diameter++;
    }
    n++, n++;
    printf("%d\n", diameter);
  }
  return 0;
}
