#include <bits/stdc++.h>
using namespace std;
namespace IOstream {
template <typename T>
inline void read(T &x) {
  x = 0;
  T fl = 1;
  char c = 0;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') fl = -1;
  for (; c >= '0' && c <= '9'; c = getchar())
    x = (x << 1) + (x << 3) + (c ^ 48);
  x *= fl;
}
template <typename T>
inline T sqr(T x) {
  return x * x;
}
template <typename T>
inline void write(T x) {
  if (x < 0) putchar('-'), x *= -1;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
inline T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <typename T>
inline void writeln(T x) {
  write(x);
  puts("");
}
template <typename T>
inline void writesp(T x) {
  write(x);
  putchar(' ');
}
}  // namespace IOstream
using namespace IOstream;
const int LOG = 27;
const int N = 300000 + 5;
int fa[N][LOG + 5];
int p1[N], p2[N], dep[N];
int n, m, cnt1, cnt2, MX = 0;
int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (int i = LOG; ~i; i--)
    if (dep[fa[u][i]] >= dep[v]) u = fa[u][i];
  if (u == v) return u;
  for (int i = LOG; ~i; i--) {
    if (fa[u][i] != fa[v][i]) {
      u = fa[u][i];
      v = fa[v][i];
    }
  }
  return fa[u][0];
}
int dis(int u, int v) {
  int LCA = lca(u, v);
  return dep[u] + dep[v] - 2 * dep[LCA];
}
int main() {
  read(n);
  p1[++cnt1] = 1;
  for (int i = 2, y; i <= n + 1; i++) {
    read(y);
    fa[i][0] = y;
    dep[i] = dep[y] + 1;
    for (int j = 1; j <= LOG; j++) fa[i][j] = fa[fa[i][j - 1]][j - 1];
    int d1 = cnt1 == 0 ? 0 : dis(p1[1], i), d2 = cnt2 == 0 ? 0 : dis(p2[1], i);
    if (d1 > MX) {
      for (int j = 1; j <= cnt2; j++)
        if (dis(p2[j], i) == d1) p1[++cnt1] = p2[j];
      cnt2 = 1;
      p2[1] = i;
    } else if (d2 > MX) {
      for (int j = 1; j <= cnt1; j++)
        if (dis(p1[j], i) == d2) p2[++cnt2] = p1[j];
      cnt1 = 1;
      p1[1] = i;
    } else if (d1 == MX)
      p2[++cnt2] = i;
    else if (d2 == MX)
      p1[++cnt1] = i;
    MX = max(MX, max(d1, d2));
    writeln(cnt1 + cnt2);
  }
  return 0;
}
