#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10, L = 22;
int a[N], t[N], h[N], he[N], par[N][L], pr[N], dis[N][L], sm = 0, mx_down[N],
                                                          down[N];
vector<int> g[N], vec;
vector<pair<int, int> > v[N], q[N];
bool mark[N];
void dfs(int v, int p) {
  int sum = 0, mx = 0;
  sm++;
  vec.push_back(v);
  for (int u : g[v])
    if (u != p && !mark[u]) {
      dfs(u, v);
      mx = max(mx, down[u]);
      sum += down[u];
    }
  down[v] = sum + 1;
  mx_down[v] = mx;
}
int find_centroid(int v) {
  sm = 0;
  vec.clear();
  dfs(v, v);
  int cent = -1;
  for (int u : vec)
    if (sm - down[u] <= sm / 2 && mx_down[u] <= sm / 2) cent = u;
  return cent;
}
void Dfs(int v, int p, int hei, int s) {
  dis[v][hei] = s;
  for (int u : g[v])
    if (u != p && !mark[u]) Dfs(u, v, hei, s + 1);
}
void solve(int v, int p, int hei) {
  v = find_centroid(v);
  mark[v] = true;
  pr[v] = p;
  he[v] = hei;
  Dfs(v, v, hei, 0);
  for (int u : g[v])
    if (!mark[u]) solve(u, v, hei + 1);
}
inline int parent(int v, int x) {
  for (int i = 0; i < L; i++)
    if ((1 << i) & x) v = par[v][i];
  return v;
}
inline int lca(int u, int v) {
  if (h[u] > h[v]) swap(u, v);
  v = parent(v, h[v] - h[u]);
  if (v == u) return v;
  for (int i = L - 1; i >= 0; i--)
    if (par[u][i] != par[v][i]) {
      u = par[u][i];
      v = par[v][i];
    }
  return par[v][0];
}
inline int dist(int u, int v) {
  int p = lca(u, v);
  return h[u] + h[v] - 2 * h[p];
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int m;
  cin >> m;
  int l = 0, r = 0, mx = 0;
  for (int i = 1; i <= m; i++) {
    int p;
    cin >> p;
    p--;
    par[i][0] = p;
    h[i] = h[p] + 1;
    g[p].push_back(i);
    g[i].push_back(p);
    for (int j = 1; j < L; j++) par[i][j] = par[par[i][j - 1]][j - 1];
    int d = dist(i, l);
    if (d >= mx) a[i] = 1;
    if (d > mx) {
      mx = d;
      v[i].push_back({d, i});
      r = i;
    }
    d = dist(i, r);
    if (d >= mx) a[i] = 1;
    if (d > mx) {
      mx = d;
      v[i].push_back({d, i});
      l = i;
    }
  }
  a[0] = 1;
  solve(0, -1, 0);
  for (int j = m; j >= 0; j--) {
    if (!a[j]) continue;
    int best = m + 1;
    int z = j;
    while (z != -1) {
      int d = dis[j][he[z]];
      auto it = upper_bound(q[z].rbegin(), q[z].rend(), make_pair(d + 1, -1));
      if (it != q[z].rend()) {
        best = min(best, it->second);
      }
      z = pr[z];
    }
    t[best]++;
    if (v[j].size()) {
      pair<int, int> x = v[j][0];
      int d = x.first, i = x.second;
      int ind = i;
      while (i != -1) {
        int ds = d - dis[ind][he[i]];
        if (ds > 0) {
          while (q[i].size() && q[i].back().first <= ds) q[i].pop_back();
          q[i].push_back({ds, ind});
        }
        i = pr[i];
      }
    }
  }
  int ans = 1;
  for (int i = 1; i <= m; i++) {
    ans += a[i];
    ans -= t[i];
    cout << ans << "\n";
  }
  return 0;
}
