#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <cmath>
#include <climits>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <functional>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep(a,b) for(int a = 0;a<b;a++)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(),a.end()
const int inf = 1e9;
const ll infl = 1e18;
const int ize = 200007;
ll tr[ize];
void ustaw(int l, int r, int v){
l+=ize;
r+=ize;
tr[l] = v;
tr[r] = v;
while(l/2 != r/2){
if(l % 2 == 0){
tr[l+1] = v;
}
if(r % 2 == 1){
tr[r-1] = v;
}
l/=2;r/=2;
}
}
ll check(ll p){
p += ize;
ll ans = tr[p];
while(p > 0){
if(tr[p] != 0){
ans = tr[p];
}
p/=2;
}
return ans;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n;
cin >> n;
vector<ll> a(n);
rep(i, n){
cin >> a[i];
}
unordered_map<ll, ll> ost_wyst;
ll pocz_ost = -1;
ll kon_ost = -1;
rep(i, n){
ll k = i+1;
ll ost = ost_wyst[a[i]];
if(ost != 0 && !(ost >= pocz_ost && ost <= kon_ost)){
ustaw(ost, k, a[i]);
pocz_ost = ost;
kon_ost = k;
}
else{
ustaw(k, k, a[i]);
}
ost_wyst[a[i]] = k;
}
rep(i, n){
cout << check(i+1) << "\n";
}
return 0;
}