#include <bits/stdc++.h>
using namespace std;
const long long modn = 1000000007;
inline long long mod(long long x) { return x % modn; }
template <class num>
inline void rd(num &x) {
  char c;
  while (isspace(c = getchar()))
    ;
  bool neg = false;
  if (!isdigit(c))
    neg = (c == '-'), x = 0;
  else
    x = c - '0';
  while (isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - '0';
  if (neg) x = -x;
}
int n;
const int N = 312345;
int lc[N][20], h[N];
int p[N];
int dist(int a, int b) {
  int d = h[a] + h[b];
  if (h[a] < h[b]) swap(a, b);
  for (int i = 19; i >= 0; i--)
    if (h[lc[a][i]] >= h[b]) a = lc[a][i];
  if (a != b) {
    for (int i = 19; i >= 0; i--)
      if (lc[a][i] != lc[b][i]) a = lc[a][i], b = lc[b][i];
    a = lc[a][0];
  }
  return d - 2 * h[a];
}
int sz[N], ds[N][20];
int pc[N], ch[N];
vector<int> adj[N];
int dfs(int u, int p) {
  sz[u] = 1;
  for (int v : adj[u])
    if (v != p && !ch[v]) sz[u] += dfs(v, u);
  return sz[u];
}
void mrk(int u, int p, int d, int lvl) {
  ds[u][lvl] = d;
  for (int v : adj[u])
    if (v != p && !ch[v]) mrk(v, u, d + 1, lvl);
}
void go(int u, int pc, int lvl) {
  dfs(u, -1);
  int n = sz[u];
  int c = u;
  int p = -1;
  while (true) {
    bool any = false;
    for (int v : adj[c])
      if (v != p && !ch[v] && sz[v] > n / 2) {
        p = c;
        c = v;
        any = true;
        break;
      }
    if (!any) break;
  }
  ::pc[c] = pc;
  ch[c] = lvl;
  for (int v : adj[c])
    if (!ch[v]) mrk(v, -1, 1, lvl);
  for (int v : adj[c])
    if (!ch[v]) go(v, c, lvl + 1);
}
struct cmp {
  bool operator()(pair<int, int> a, pair<int, int> b) {
    int lvl = a.second;
    assert(lvl == b.second);
    int u = a.first, v = b.first;
    if (ds[u][lvl] != ds[v][lvl]) return ds[u][lvl] < ds[v][lvl];
    return u < v;
  }
};
set<pair<int, int>, cmp> s[N];
int main() {
  int i, j;
  rd(n);
  int a = 0, b = 0;
  int mxd = 0;
  for (i = 1; i <= n; i++) {
    rd(p[i]);
    p[i]--;
    h[i] = h[p[i]] + 1;
    lc[i][0] = p[i];
    for (int b = 1; b < 20; b++) lc[i][b] = lc[lc[i][b - 1]][b - 1];
    adj[p[i]].push_back(i);
    adj[i].push_back(p[i]);
  }
  go(0, -1, 1);
  set<int> nds;
  nds.insert(0);
  i = 0;
  for (int x = i; x != -1; x = pc[x]) {
    s[x].insert(pair<int, int>(i, ch[x]));
  }
  for (i = 1; i <= n; i++) {
    int da = dist(i, a);
    int db = dist(i, b);
    if (da < mxd && db < mxd) {
    } else if (da <= mxd && db <= mxd) {
      nds.insert(i);
    } else {
      mxd = max(da, db);
      if (da >= db) {
        b = i;
      } else {
        a = i;
      }
      nds.insert(i);
      for (int x = i; x != -1; x = pc[x]) {
        while (!s[x].empty()) {
          int j = s[x].begin()->first;
          if (ds[i][ch[x]] + ds[j][ch[x]] < mxd) {
            nds.erase(j);
            for (int k = j; k != -1; k = pc[k])
              s[k].erase(pair<int, int>(j, ch[k]));
          } else
            break;
        }
      }
    }
    if (nds.count(i))
      for (int x = i; x != -1; x = pc[x]) {
        s[x].insert(pair<int, int>(i, ch[x]));
      }
    printf("%d\n", int(nds.size()));
  }
}
