#include <bits/stdc++.h>
using namespace std;
const int t = 19;
int n, mxd, dep[(300010)], fa[(300010)][24];
vector<int> s1, s2;
inline int read() {
  int w = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    w = (w << 3) + (w << 1) + (ch ^ 48);
    ch = getchar();
  }
  return w;
}
inline void add(int st, int f) {
  dep[st] = dep[fa[st][0] = f] + 1;
  for (int i = 1; i <= t; i++) fa[st][i] = fa[fa[st][i - 1]][i - 1];
}
inline int lca(int a, int b) {
  if (dep[a] > dep[b]) swap(a, b);
  for (int i = t; i >= 0; i--)
    if (dep[fa[b][i]] >= dep[a]) b = fa[b][i];
  if (a == b) return a;
  for (int i = t; i >= 0; i--)
    if (fa[a][i] != fa[b][i]) a = fa[a][i], b = fa[b][i];
  return fa[a][0];
}
inline int dis(int a, int b) { return dep[a] + dep[b] - (dep[lca(a, b)] << 1); }
int main() {
  int n = read();
  add(1, 0);
  s1.push_back(1);
  for (int i = 2; i <= n + 1; i++) {
    add(i, read());
    int d1 = s1.empty() ? 0 : dis(i, s1[0]);
    int d2 = s2.empty() ? 0 : dis(i, s2[0]);
    if (max(d1, d2) > mxd) {
      mxd = max(d1, d2);
      if (mxd == d1) {
        for (int j = 0; j < (int)s2.size(); j++)
          if (dis(i, s2[j]) == d1) s1.push_back(s2[j]);
        s2.clear();
      } else {
        for (int j = 0; j < (int)s1.size(); j++)
          if (dis(i, s1[j]) == d2) s2.push_back(s1[j]);
        s1.clear();
      }
    }
    if (max(d1, d2) == mxd) {
      if (mxd == d1)
        s2.push_back(i);
      else
        s1.push_back(i);
    }
    printf("%d\n", (int)s1.size() + (int)s2.size());
  }
  return 0;
}
