#include <iostream>
#include <vector>

using namespace std;

int N;
vector<vector<int>> t;
vector<bool> used;
int eval(int root) {
	int ret = 0;
	for (int i = 0; i < t[root].size(); i++) {
		int node = t[root][i];
		if (!used[root] && t[node].size() == 0) {
			used[root] = used[node] = true;
			ret++;
		} else ret += eval(node);
		if (!used[root] && !used[node]) {
			used[root] = used[node] = true;
			ret++;
		}
	}
	return ret;
}
int main(void) {
	cin >> N;
	t = vector<vector<int>>(N+1, vector<int>(0));
	for (int i = 1; i <= N; i++) {
		int pi;
		cin >> pi;
		used = vector<bool>(N+1, false);
		t[pi].push_back(i);
		cout << eval(0) << endl;
	}
}