#include <bits/stdc++.h>
using namespace std;
const int N = 3 * 1e5 + 5;
int n, num, bj = 0, f[N][21], d[N], maxd;
vector<int> s1, s2;
int lca(int x, int y) {
  if (d[x] < d[y]) swap(x, y);
  int k = log(n + 1) / log(2);
  for (int i = k; i >= 0; i--)
    if (f[x][i] && d[f[x][i]] >= d[y]) x = f[x][i];
  if (x == y) return x;
  for (int i = k; i >= 0; i--)
    if (f[x][i] && f[x][i] != f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
int Lca(int x, int y) {
  int c = lca(x, y);
  return d[x] + d[y] - d[c] - d[f[c][0]];
}
void Solve(int x) {
  int d1 = (s1.size() ? Lca(s1[0], x) : 0);
  int d2 = (s2.size() ? Lca(s2[0], x) : 0);
  if (d1 > maxd) {
    maxd = d1;
    for (int i = 0; i < s2.size(); i++) {
      int y = s2[i];
      if (Lca(y, x) == maxd) s1.push_back(y);
    }
    s2.clear();
    s2.push_back(x);
  } else if (d2 > maxd) {
    maxd = d2;
    for (int i = 0; i < s1.size(); i++) {
      int y = s1[i];
      if (Lca(x, y) == maxd) s2.push_back(y);
    }
    s1.clear();
    s1.push_back(x);
  } else {
    if (d1 == maxd)
      s2.push_back(x);
    else if (d2 == maxd)
      s1.push_back(x);
  }
}
int main() {
  scanf("%d", &n);
  num = 1;
  maxd = 1;
  d[1] = 1;
  s1.push_back(1);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    ++num;
    d[num] = d[x] + 1;
    f[num][0] = x;
    for (int j = 1; j <= 20; j++) f[num][j] = f[f[num][j - 1]][j - 1];
    Solve(num);
    printf("%d\n", s1.size() + s2.size());
  }
  return 0;
}
