#include <bits/stdc++.h>
int max1[1000001], max2[1000001], ans[1000001], parent[1000001];
void swap(int* i, int* j) {
  int t = *i;
  *i = *j;
  *j = t;
}
int max(int x, int y) { return (x > y) ? x : y; }
int main(int argc, const char* argv[]) {
  int i, n, num = 1, node;
  memset(max1, 0, sizeof(max1));
  memset(max2, 0, sizeof(max2));
  parent[1] = 0;
  scanf("%d\n", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", parent + (++num));
    ans[num] = 1;
    node = num;
    while (node > 1) {
      int flag = 0;
      if (ans[node] > max2[parent[node]]) max2[parent[node]] = ans[node];
      if (max2[parent[node]] > max1[parent[node]])
        swap(&max1[parent[node]], &max2[parent[node]]);
      if (max(max1[parent[node]], max2[parent[node]] + 1) > ans[parent[node]]) {
        flag = 1;
        ans[parent[node]] = max(max1[parent[node]], max2[parent[node]] + 1);
        node = parent[node];
        if (max1[1] == max2[1] && node == 1) ans[1] -= 1;
      }
      if (!flag) break;
    }
    printf("%d ", ans[1]);
  }
  return 0;
}
