#include <bits/stdc++.h>
using namespace std;
template <class T>
void dbg(const char* xn, T x) {
  if (0) cout << xn << ": " << x << "\n";
}
template <class T, class... TA>
void dbg(const char* xn, T x, TA... t) {
  while (*xn != ',')
    if (0) cout << *xn++;
  if (0) cout << ": " << x << ",";
  dbg(xn + 1, t...);
}
template <class T>
inline bool upd_max(T& x, T y) {
  return y > x ? x = y, true : false;
}
template <class T>
inline bool upd_min(T& x, T y) {
  return y < x ? x = y, true : false;
}
const int N = 1000007;
const int logN = 20;
long long n, depth[N], p[N][logN], diameter = 0;
set<long long> S1, S2;
void preprocessLCA() {
  for (long long i = 1; i <= (n); ++i)
    for (long long j = 0; j < (logN); ++j) p[i][j] = -1;
  p[1][0] = 1;
}
long long LCA(long long a, long long b) {
  if (depth[a] < depth[b]) swap(a, b);
  long long dis = (depth[a] - depth[b]);
  while (dis > 0)
    a = p[a][(63 - __builtin_clzll(dis))],
    dis -= (1LL << ((63 - __builtin_clzll(dis))));
  if (a == b) return b;
  for (long long j = logN - 1; j >= 0; --j) {
    if ((p[a][j] != -1) && (p[a][j] != p[b][j])) a = p[a][j], b = p[b][j];
  }
  return p[a][0];
}
long long distance(long long a, long long b) {
  long long l = LCA(a, b);
  return depth[a] + depth[b] - 2 * depth[l];
}
void addVertex(long long v) {
  cin >> p[v][0];
  depth[v] = depth[p[v][0]] + 1;
  for (long long i = 1; i < 20; ++i) {
    if (p[v][i - 1] == -1) break;
    p[v][i] = p[p[v][i - 1]][i - 1];
  }
  long long disC1 = S1.empty() ? -1 : distance(v, *S1.begin());
  long long disC2 = S2.empty() ? -1 : distance(v, *S2.begin());
  if (max(disC1, disC2) < diameter)
    return;
  else if (max(disC1, disC2) > diameter) {
    diameter = max(disC1, disC2);
    if (disC1 >= disC2) {
      for (auto u : S2) {
        if (distance(v, u) == diameter) S1.insert(u);
      }
      S2.clear();
      S2.insert(v);
    } else {
      for (auto u : S1) {
        if (distance(v, u) == diameter) S2.insert(u);
      }
      S1.clear();
      S1.insert(v);
    }
  } else {
    if (disC1 >= disC2)
      S2.insert(v);
    else
      S1.insert(v);
  }
}
void solve() {
  cin >> n;
  ++n;
  preprocessLCA();
  S1.insert(1);
  for (long long i = 2; i <= n; ++i) {
    addVertex(i);
    long long ans = ((long long)(S1).size()) + ((long long)(S2).size());
    cout << ans << '\n';
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}
