#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int dep[N], n, fa[N][22], d1, d2, len;
set<int> s1, s2;
set<int>::iterator t;
int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  int del = dep[x] - dep[y];
  for (int i = 20; i >= 0; i--)
    if (del & (1 << i)) x = fa[x][i];
  if (x == y) return x;
  for (int i = 20; i >= 0; i--)
    if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  return fa[x][0];
}
int dis(int x, int y) { return dep[x] + dep[y] - 2 * dep[lca(x, y)]; }
void init() {
  for (int j = 1; j <= 20; j++)
    for (int i = 2; i <= n + 1; i++) fa[i][j] = fa[fa[i][j - 1]][j - 1];
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n + 1; i++)
    scanf("%d", &fa[i][0]), dep[i] = dep[fa[i][0]] + 1;
  init();
  s1.insert(1);
  for (int i = 2; i <= n + 1; i++) {
    d1 = (int)s1.size() == 0 ? 0 : dis(i, *s1.begin());
    d2 = (int)s2.size() == 0 ? 0 : dis(i, *s2.begin());
    if (max(d1, d2) > len) {
      if (d1 > len) {
        for (t = s2.begin(); t != s2.end(); ++t)
          if (dis(i, *t) == d1) s1.insert(*t);
        s2.clear();
        s2.insert(i);
      } else {
        for (t = s1.begin(); t != s1.end(); ++t)
          if (dis(i, *t) == d2) s2.insert(*t);
        s1.clear();
        s1.insert(i);
      }
      len = max(d1, d2);
    } else if (max(d1, d2) == len) {
      if (d1 == len)
        s2.insert(i);
      else
        s1.insert(i);
    }
    printf("%d\n", (int)s1.size() + (int)s2.size());
  }
  return 0;
}
