#include <bits/stdc++.h>
using namespace std;
inline int read() {
  register int data = 0, w = 1;
  char ch = 0;
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    data = (data << 1) + (data << 3) + (ch ^ 48), ch = getchar();
  return data * w;
}
int p[300005][20], dep[1000005];
void add(int x) {
  dep[x] = dep[p[x][0]] + 1;
  for (int i = 1; i <= 18; i++) p[x][i] = p[p[x][i - 1]][i - 1];
}
int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 18; i >= 0; i--)
    if (dep[p[x][i]] >= dep[y]) x = p[x][i];
  if (x == y) return x;
  for (int i = 18; i >= 0; i--)
    if (p[x][i] != p[y][i]) x = p[x][i], y = p[y][i];
  return p[x][0];
}
int Dis(int x, int y) { return dep[x] + dep[y] - 2 * dep[lca(x, y)]; }
vector<int> first, second;
int main() {
  int n = read() + 1;
  dep[1] = 1;
  p[2][0] = read();
  add(2);
  first.push_back(1);
  second.push_back(2);
  puts("2");
  int d = 1;
  for (int i = 3; i <= n; i++) {
    p[i][0] = read();
    add(i);
    int d1 = Dis(first[0], i), d2 = Dis(second[0], i);
    if (max(d1, d2) > d) {
      d = max(d1, d2);
      if (d1 == d) {
        for (auto u : second)
          if (Dis(i, u) == d1) first.push_back(u);
        second.clear();
      } else {
        for (auto u : first)
          if (Dis(i, u) == d2) second.push_back(u);
        first.clear();
      }
    }
    if (max(d1, d2) == d) (d1 == d ? second : first).push_back(i);
    cout << first.size() + second.size() << "\n";
  }
  return 0;
}
