#include <bits/stdc++.h>
using namespace std;
const int N = int(4e5) + 5;
const int inf = (int)1e9 + 7;
int n;
int up[N][20], h[N], ans[N], p[N];
int f1 = 1, f2 = -1;
pair<int, int> far[N];
void add(int p, int v) {
  up[v][0] = p;
  h[v] = h[p] + 1;
  for (int j = 1; j < 20; ++j) {
    up[v][j] = up[up[v][j - 1]][j - 1];
  }
}
int lca(int x, int y) {
  if (h[x] < h[y]) {
    swap(x, y);
  }
  for (int j = 19; j >= 0; --j) {
    if (((h[x] - h[y]) >> j) & 1) {
      x = up[x][j];
    }
  }
  if (x == y) {
    return x;
  }
  for (int j = 19; j >= 0; --j) {
    if (up[x][j] && up[y][j] && up[x][j] != up[y][j]) {
      x = up[x][j];
      y = up[y][j];
    }
  }
  return up[x][0];
}
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);
    add(x, 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;
}
