#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int dep[N], f[N][20], d = 0;
int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 19; i >= 0; i--)
    if (dep[f[x][i]] >= dep[y]) x = f[x][i];
  if (x == y) return x;
  for (int i = 19; i >= 0; i--)
    if (f[x][i] != f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
int dis(int x, int y) { return dep[x] + dep[y] - 2 * dep[lca(x, y)]; }
vector<int> p1, p2;
void solve(int x) {
  if (p1.size() && dis(p1[0], x) > d) {
    ++d;
    for (int y : p2)
      if (dis(x, y) == d) p1.push_back(y);
    p2.clear();
    p2.push_back(x);
  } else if (p2.size() && dis(p2[0], x) > d) {
    ++d;
    for (int y : p1)
      if (dis(x, y) == d) p2.push_back(y);
    p1.clear();
    p1.push_back(x);
  } else if (p1.size() && dis(p1[0], x) == d) {
    p2.push_back(x);
  } else if (p2.size() && dis(p2[0], x) == d) {
    p1.push_back(x);
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n, fa;
  p1.push_back(1);
  cin >> n;
  for (int i = 1; i <= (n); ++i) {
    int x = i + 1;
    cin >> fa;
    dep[x] = dep[fa] + 1;
    f[x][0] = fa;
    for (int i = 1; i <= 19; i++) f[x][i] = f[f[x][i - 1]][i - 1];
    solve(x);
    cout << p1.size() + p2.size() << endl;
  }
  return 0;
}
