#include <bits/stdc++.h>
using namespace std;
const int N = int(4e5) + 5;
const int inf = (int)1e9 + 7;
int n;
int l[N], lg[N * 2], h[N], T;
int m[20][N * 2];
int ans[N], p[N];
int f1 = 1, f2 = -1;
pair<int, int> far[N];
vector<int> g[N];
int getx(int x, int y) { return h[x] < h[y] ? x : y; }
void dfs(int v, int p) {
  l[v] = ++T;
  m[0][T] = v;
  h[v] = h[p] + 1;
  for (int i : g[v]) {
    if (i == p) {
      continue;
    }
    dfs(i, v);
    m[0][++T] = v;
  }
}
void calc() {
  for (int i = 2; i <= T; ++i) {
    lg[i] = lg[i / 2] + 1;
  }
  for (int l = 1; l < 20; ++l) {
    for (int i = 1; i + (1 << l) - 1 <= T; ++i) {
      m[l][i] = getx(m[l - 1][i], m[l - 1][i + (1 << (l - 1))]);
    }
  }
}
int get(int l, int r) {
  int z = lg[r - l + 1];
  return getx(m[z][l], m[z][r - (1 << z) + 1]);
}
int lca(int x, int y) {
  if (l[x] > l[y]) {
    swap(x, y);
  }
  return get(l[x], l[y]);
}
int dist(int x, int y) { return h[x] + h[y] - 2 * h[lca(x, y)]; }
int ok(int id, int v) {
  int now = max(dist(far[id].first, v), dist(far[id].second, v));
  return now >= p[id];
}
int main() {
  scanf("%d", &n);
  ++n;
  far[1] = make_pair(1, 1);
  for (int i = 2; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    g[i].push_back(x);
    g[x].push_back(i);
  }
  dfs(1, 0);
  calc();
  for (int i = 2; i <= n; ++i) {
    if (f2 == -1) {
      f2 = i;
    } else {
      if (dist(f1, i) > dist(f1, f2)) {
        f2 = i;
      }
      if (dist(f2, i) > dist(f1, f2)) {
        f1 = i;
      }
    }
    p[i] = max(p[i - 1], dist(f1, f2));
    far[i] = make_pair(f1, f2);
  }
  for (int i = 1; i <= n; ++i) {
    int lf = i, rg = n;
    while (rg - lf > 1) {
      int mid = (lf + rg) >> 1;
      if (ok(mid, i)) {
        lf = mid;
      } else {
        rg = mid;
      }
    }
    int wow = -1;
    for (int j : {rg, lf}) {
      if (ok(j, i)) {
        wow = j;
        break;
      }
    }
    if (wow != -1) {
      ans[i]++;
      ans[wow + 1]--;
    }
  }
  for (int i = 2; i <= n; ++i) {
    ans[i] += ans[i - 1];
    printf("%d\n", ans[i]);
  }
  return 0;
}
