#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const ll MOD=1000000007;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
ll n;
cin >> n;
vector<ll> lst(n+1);
map<ll,ll> Reference;
ll cnt=0;
vector<vector<ll>> OrderLst;
for(ll i=1;i<=n;i++){
cin >> lst[i];
if(Reference.find(lst[i])==Reference.end()){
Reference[lst[i]]=cnt++;
OrderLst.push_back({lst[i],i,i});
}
else{
OrderLst[Reference[lst[i]]][2]=i;
}
}
vector<vector<ll>> OldOrderLst=OrderLst;
sort(OrderLst.begin(),OrderLst.end(),[](vector<ll> a, vector<ll> b){
return a[2]<b[2];
});
vector<ll> AnsLst(n+1);
ll LeftMost=-1;
ll RightMost=-1;
ll Color=OrderLst[0][0];
LeftMost=OrderLst[0][1];
RightMost=OrderLst[0][2];
ll CurrPtr=RightMost+1;
for(ll i=LeftMost;i<=RightMost;i++){
AnsLst[i]=Color;
}
while(CurrPtr<=n){
Color=lst[CurrPtr];
LeftMost=CurrPtr;
RightMost=OldOrderLst[Reference[Color]][2];
for(ll i=LeftMost;i<=RightMost;i++){
AnsLst[i]=Color;
}
CurrPtr=RightMost+1;
}
for(ll i=1;i<=n;i++){
cout << AnsLst[i] << "/n";
}
}