#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long double pi = acos(-1);
int n, par[20][200010], prof[200010];
void add(int v, int p) {
  par[0][v] = p;
  for (int i = 1; i < 20; i++)
    if (par[i - 1][v] == -1)
      par[i][v] = -1;
    else
      par[i][v] = par[i - 1][par[i - 1][v]];
}
int lca(int u, int v) {
  for (int i = 19; i >= 0; i--)
    if (prof[u] - (1 << i) >= prof[v]) u = par[i][u];
  if (u == v) return u;
  for (int i = 19; i >= 0; i--)
    if (par[i][u] != par[i][v]) u = par[i][u], v = par[i][v];
  return par[0][u];
}
int solve(int u, int v) {
  int p;
  if (prof[u] < prof[v])
    p = lca(v, u);
  else
    p = lca(u, v);
  return prof[v] + prof[u] - 2 * prof[p];
}
int main() {
  scanf("%d", &n);
  memset(par, -1, sizeof(par));
  memset(prof, 0, sizeof(0));
  int x = 0, y = 0, pai = 0;
  int resp = 0;
  prof[0] = 0;
  for (int i = 1; i < n; i++) {
    scanf("%d", &pai);
    pai--;
    prof[i] = prof[pai] + 1;
    add(i, pai);
    if (solve(i, x) > resp)
      y = i, resp = solve(i, x);
    else if (solve(i, y) > resp)
      x = i, resp = solve(i, y);
    printf("%d ", resp);
  }
  printf("\n");
  return 0;
}
