#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n, dep[N], f[N][30];
vector<int> G[N];
vector<int> s1, s2;
void dfs(int u, int fa) {
  dep[u] = dep[fa] + 1;
  f[u][0] = fa;
  for (int v : G[u]) dfs(v, u);
}
void init() {
  for (int j = 1; (1 << j) <= n; j++)
    for (int i = 1; i <= n; i++) f[i][j] = f[f[i][j - 1]][j - 1];
}
int LCA(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  int d = dep[u] - dep[v];
  for (int i = 0; i < 21; i++)
    if ((1 << i) & d) u = f[u][i];
  if (u == v) return u;
  for (int i = 20; i >= 0; i--) {
    if (f[u][i] != f[v][i]) {
      u = f[u][i];
      v = f[v][i];
    }
  }
  u = f[u][0];
  return u;
}
int dis(int x, int y) { return dep[x] + dep[y] - 2 * dep[LCA(x, y)]; }
int main() {
  scanf("%d", &n);
  n++;
  for (int i = 2; i <= n; i++) {
    int v;
    scanf("%d", &v);
    G[v].push_back(i);
  }
  dfs(1, 0);
  init();
  s1.push_back(1);
  int d = 0;
  for (int i = 2; i <= n; i++) {
    int d1 = s1.size() ? dis(s1[0], i) : 0;
    int d2 = s2.size() ? dis(s2[0], i) : 0;
    if (max(d1, d2) > d) {
      d = max(d1, d2);
      if (d1 == d) {
        for (int v : s2)
          if (dis(v, i) == d) s1.push_back(v);
        s2.clear();
        s2.push_back(i);
      } else {
        for (int v : s1)
          if (dis(v, i) == d) s2.push_back(v);
        s1.clear();
        s1.push_back(i);
      }
    } else if (max(d1, d2) == d) {
      if (d1 == d)
        s2.push_back(i);
      else
        s1.push_back(i);
    }
    cout << s1.size() + s2.size() << endl;
  }
}
