#include <bits/stdc++.h>
using LL = long long;
const int N = 200000 + 5;
const int LOG = 18;
int plca[N][LOG], dis[N], n;
int result[N];
int get_lca(int a, int b) {
  if (dis[a] < dis[b]) std::swap(a, b);
  for (int i = 0; i < LOG; ++i)
    if (dis[a] - dis[b] >> i & 1) a = plca[a][i];
  if (a == b) return a;
  for (int i = LOG - 1; i >= 0; --i) {
    if (plca[a][i] != plca[b][i]) {
      a = plca[a][i];
      b = plca[b][i];
    }
  }
  return plca[a][0];
}
int get_dis(int a, int b) { return dis[a] + dis[b] - 2 * dis[get_lca(a, b)]; }
int main() {
  scanf("%d", &n);
  int da = 1, db = 1;
  for (int i = 2; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    plca[i][0] = x;
    dis[i] = dis[x] + 1;
    for (int j = 1; j < LOG; ++j) {
      plca[i][j] = plca[plca[i][j - 1]][j - 1];
    }
    if (get_dis(i, da) > get_dis(da, db))
      db = i;
    else if (get_dis(i, db) > get_dis(da, db))
      da = i;
    result[i] = get_dis(da, db);
  }
  for (int i = 2; i <= n; ++i) {
    printf("%d%c", result[i], " \n"[i == n]);
  }
}
