#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define en exit(0);
using namespace std;
const int N = 2e5 + 5;
const int INF = 1e9 + 5;
int a[N];
int main()
{
fio
// ifstream cin("in.in");
int n;
cin >> n;
for(int i = 1;i <= n;i++)
{
cin >> a[i];
int lst = -1;
for(int j = 1;j < i;j++)
if(a[j] == a[i])
lst = j;
if(lst != -1)
for(int j = lst;j <= i;j++)
a[j] = a[i];
}
for(int i = 1;i <= n;i++)
cout << a[i] << " ";
return 0;
}