#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int dp[N][20], dep[N], n, dd;
void add_edge(int pos, int fa) {
  dp[pos][0] = fa;
  dep[pos] = dep[fa] + 1;
  for (int i = 1; i < 20; i++) dp[pos][i] = dp[dp[pos][i - 1]][i - 1];
}
int lca(int a, int b) {
  if (dep[a] < dep[b]) swap(a, b);
  for (int i = 19; i >= 0; --i)
    if (dep[dp[a][i]] >= dep[b]) a = dp[a][i];
  if (a == b) return a;
  for (int i = 19; i >= 0; --i)
    if (dp[a][i] != dp[b][i]) a = dp[a][i], b = dp[b][i];
  return dp[a][0];
}
inline int dis(int a, int b) { return dep[a] + dep[b] - dep[lca(a, b)] * 2; }
vector<int> v1, v2;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  ++n;
  add_edge(1, 1);
  v1.push_back(1);
  for (int i = 2; i <= n; i++) {
    int tmp;
    cin >> tmp;
    add_edge(i, tmp);
    int d1 = v1.empty() ? 0 : dis(v1[0], i),
        d2 = v2.empty() ? 0 : dis(v2[0], i);
    if (max(d1, d2) > dd) {
      dd = max(d1, d2);
      if (d1 == dd) {
        for (auto &j : v2)
          if (dis(i, j) == d1) v1.push_back(j);
        v2.clear();
      } else {
        for (auto &j : v1)
          if (dis(i, j) == d2) v2.push_back(j);
        v1.clear();
      }
    }
    if (max(d1, d2) == dd) (dd == d1 ? v2 : v1).push_back(i);
    cout << v1.size() + v2.size() << endl;
  }
  return 0;
}
