#include <bits/stdc++.h>
using namespace std;
const long long ml = 3e5 + 101;
long long n;
long long js, ma;
long long f[ml][21], dep[ml];
inline long long read() {
  long long r = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) r = (r << 1) + (r << 3) + (c ^ 48), c = getchar();
  return r * f;
}
inline void wr(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) wr(x / 10);
  putchar(x % 10 + '0');
}
inline void port(long long x, char s) {
  wr(x);
  putchar(s);
}
long long lca(long long x, long long y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (long long i = 20; i >= 0; i--)
    if (dep[f[x][i]] >= dep[y]) x = f[x][i];
  if (x == y) return x;
  for (long long i = 20; i >= 0; i--)
    if (f[x][i] != f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
long long dis(long long x, long long y) {
  return dep[x] + dep[y] - (dep[lca(x, y)] << 1);
}
void insert(long long x, long long fa) {
  dep[x] = dep[f[x][0] = fa] + 1;
  for (long long i = 1; i <= 20; i++) f[x][i] = f[f[x][i - 1]][i - 1];
}
vector<long long> s1, s2;
int main() {
  n = read();
  s1.push_back(1);
  insert(1, 0);
  for (long long i = 2; i <= n + 1; i++) {
    long long x = read();
    insert(i, x);
    long long d1 = s1.empty() ? 0 : dis(i, s1[0]);
    long long d2 = s2.empty() ? 0 : dis(i, s2[0]);
    if (((d1) > (d2) ? (d1) : (d2)) > ma) {
      ma = ((d1) > (d2) ? (d1) : (d2));
      if (ma == d1) {
        long long tmp = s2.size();
        for (long long j = 0; j < tmp; j++)
          if (dis(s2[j], i) == ma) s1.push_back(s2[j]);
        s2.clear();
      } else {
        long long tmp = s1.size();
        for (long long j = 0; j < tmp; j++)
          if (dis(s1[j], i) == ma) s1.push_back(s1[j]);
        s1.clear();
      }
    }
    if (ma == ((d1) > (d2) ? (d1) : (d2))) (ma == d1 ? s2 : s1).push_back(i);
    port(s1.size() + s2.size(), '\n');
  }
  return 0;
}
