#include <bits/stdc++.h>
using namespace std;
const int MAXBUF = 1 << 23;
char B[MAXBUF], *Si = B, *Ti = B;
inline char getc() {
  if (Si == Ti) Ti = (Si = B) + fread(B, 1, MAXBUF, stdin);
  if (Si == Ti)
    return 0;
  else
    return *Si++;
}
template <class T>
inline void read(T &a) {
  static char c;
  static int fh;
  while (((c = getc()) < '0' || c > '9') && c != '-')
    ;
  if (c == '-')
    fh = -1, a = 0;
  else
    fh = 1, a = c - '0';
  while ((c = getc()) <= '9' && c >= '0') a = (a << 3) + (a << 1) + c - '0';
  if (fh == -1) a = -a;
}
char Buff[MAXBUF], *sti = Buff;
template <class T>
inline void write(T a) {
  if (a == 0) {
    *sti++ = '0';
    return;
  }
  if (a < 0) *sti++ = '-', a = -a;
  static char c[20];
  static int c0;
  c0 = 0;
  while (a) c[c0++] = a % 10 + '0', a /= 10;
  while (c0--) *sti++ = c[c0];
}
int dep[300005], n;
int fa[300005][19];
int p1[300005], c1 = 0;
int p2[300005], c2 = 0;
inline int lca(int a, int b) {
  if (dep[a] < dep[b]) swap(a, b);
  int del = dep[a] - dep[b], i;
  for (i = 0; (1 << i) <= del; i++) {
    if (del & (1 << i)) a = fa[a][i];
  }
  if (a == b) return a;
  for (i = 18; i >= 0; i--) {
    if (fa[a][i] ^ fa[b][i]) {
      a = fa[a][i];
      b = fa[b][i];
    }
  }
  return fa[a][0];
}
inline int get(int a, int b) { return dep[a] + dep[b] - 2 * dep[lca(a, b)]; }
int main() {
  int i, j, mx = 0, pos;
  read(n);
  p1[++c1] = 1;
  for (i = 2; i <= n + 1; i++) {
    read(pos);
    fa[i][0] = pos;
    dep[i] = dep[pos] + 1;
    for (j = 1; (1 << j) <= dep[i]; j++) {
      fa[i][j] = fa[fa[i][j - 1]][j - 1];
    }
    int d1 = (c1 == 0 ? 0 : get(p1[1], i));
    int d2 = (c2 == 0 ? 0 : get(p2[1], i));
    if (d1 > mx) {
      for (j = 1; j <= c2; j++) {
        if (get(p2[j], i) == d1) {
          p1[++c1] = p2[j];
        }
      }
      c2 = 1;
      p2[1] = i;
    } else if (d2 > mx) {
      for (j = 1; j <= c1; j++) {
        if (get(p1[j], i) == d2) {
          p2[++c2] = p1[j];
        }
      }
      c1 = 1;
      p1[1] = i;
    } else if (d1 == mx)
      p2[++c2] = i;
    else if (d2 == mx)
      p1[++c1] = i;
    mx = max(mx, max(d1, d2));
    write(c1 + c2);
    *sti++ = '\n';
  }
  fwrite(Buff, 1, sti - Buff, stdout);
  return 0;
}
