#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>

using namespace std;

int main() {
	int n, a;

	cin >> n;
	vector<int> b(n, -1);

	map<int, pair<int, int> > num_range;

	for (int i = 0; i < n; i++) {
		cin >> a;
		auto it = num_range.find(a);

		if (it == num_range.end()) {
			num_range[a] = make_pair(i, i);
		} else {
			(*it).second.second = i;
		}
	}


	for (auto num : num_range) {
		if (num.second.second == -1) {
			continue;
		}

		for (int i = num.second.first; i <= num.second.second; i++) {
			b[i] = num.first;
		}
	}

	cout << b[0];
	for (int i = 1; i < n; i++) {
		cout << " " << b[i];
	}
	cout << endl;


	return 0;
}