#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

const int N = 5124;
int par[N];
VI edges[N];

PI dfs(int n, int v) {
  int tot = 0;
  bool some = false;
  REP(i, 0, edges[v].size()) {
    int w = edges[v][i];
    PI res = dfs(n, w);
    if (res.second) {
      some = true;
    }
    tot += res.first;
  }
  return PI(tot + (some ? 1 : 0), some ? 0 : 1);
}

int calc(int n) {
  return dfs(n, 0).first;
}


int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  par[0] = -1;
  REP(i, 0, n) {
    int pp;
    cin >> pp;
    par[i + 1] = pp;
    edges[pp].push_back(i + 1);
    cout << calc(i + 2) << "\n";
  }
}