#include <bits/stdc++.h>
using namespace std;
const int lg = 19;
int M, N, a[300010], f[300010][20], d[300010], diam, tp[300010];
vector<int> l, r, mid;
int lca(int x, int y) {
  if (d[x] > d[y]) swap(x, y);
  for (int i = 0; i <= lg; i++)
    if ((d[y] - d[x]) & (1 << i)) y = f[y][i];
  if (x == y) return x;
  for (int i = lg; i >= 0; i--)
    if (f[x][i] != f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
int dist(int x, int y) { return d[x] + d[y] - 2 * d[lca(x, y)]; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> M;
  N = M + 1;
  int i, j;
  for (i = 1; i <= M; i++) {
    cin >> a[i];
    f[i + 1][0] = a[i];
    d[i + 1] = d[a[i]] + 1;
  }
  f[1][0] = 1;
  for (i = 1; i <= N; i++)
    for (j = 1; j <= lg; j++) f[i][j] = f[f[i][j - 1]][j - 1];
  cout << 2 << "\n";
  l.push_back(1), r.push_back(2);
  tp[1] = 1, tp[2] = 2;
  diam = 1;
  for (i = 3; i <= N; i++) {
    int t = a[i - 1];
    if (tp[t] == 0) {
      int dl = dist(i, l[0]), dr = dist(i, r[0]);
      if (max(dl, dr) == diam) {
        if (dl == dr) {
          tp[i] = 3;
          mid.push_back(i);
        } else if (dl < dr)
          tp[i] = 1, l.push_back(i);
        else
          tp[i] = 2, r.push_back(i);
      }
    } else if (tp[t] == 1) {
      for (int x : l) tp[x] = 0;
      l.clear();
      tp[i] = 1;
      l.push_back(i);
      for (int x : mid) tp[x] = 2, r.push_back(x);
      mid.clear();
      diam++;
    } else if (tp[t] == 2) {
      for (int x : r) tp[x] = 0;
      r.clear();
      tp[i] = 2;
      r.push_back(i);
      for (int x : mid) tp[x] = 1, l.push_back(x);
      mid.clear();
      diam++;
    } else {
      for (int x : l) tp[x] = 2, r.push_back(x);
      l.clear();
      for (int x : mid)
        if (dist(x, i) == diam + 1) {
          tp[x] = 2, r.push_back(x);
        } else
          tp[x] = 0;
      mid.clear();
      tp[i] = 1;
      l.push_back(i);
      diam++;
    }
    cout << (l.size() + mid.size() + r.size()) << "\n";
  }
  return 0;
}
