// Kotaro << Minoz << Hayama << Cohr3141592654

// Fall...

// You know, everybody's been tellin' me what they think about me for the last few months

// ... It's too loud
// Maybe it's time I tell 'em what I think about them
// ... Can't hear it coming down the hallway stairs from the parking lot
// ... It's too loud
// ... Three's not a crowd all up in it, slow fire

// ... Don't fall on my face
// ... Don't fall on my faith, oh
// ... Don't fall on my fate
// ... Don't fall on my faith, oh
// ... Don't fall on my fate
// ... Don't fall on my

// Gotta concentrate, against the clock I race
// Got no time to waste, I'm already late, I got a marathoner's pace
// Went from addict to a workaholic, word to Dr. Dre
// In that first marijuana tape-guess I got a chronic case (yeah)
// And I ain't just blowin' smoke, 'less it's in your momma's face
// I know this time Paul and Dre
// They won't tell me what not to say (nope)
// And though me and my party days
// Have all pretty much parted ways
// You'd swear to God I forgot I'm the guy that made "Not Afraid"
// One last time for Charlamagne
// If my response is late, it's just how long it takes
// To hit my fuckin' radar, I'm so far away
// These rappers are like Hunger Games
// One minute, they're mockin' Jay
// Next minute, they get their style from Migos or they copy Drake
// Maybe I just don't know when to turn around and walk away
// But all the hate, I call it "Walk on Water" gate
// I've had as much as I can tolerate
// I'm sick and tired of waitin', I done lost my patience
// I can take all of you motherfuckers on at once
// You wanted Shady? You got him!

// ... Don't fall on my face (yeah)
// ... Don't fall on my faith, oh
// ... Don't fall on my fate (line 'em up!)
// ... Don't fall on my faith, oh (rrr!)
// ... Don't fall on my fate (look)

// Somebody tell Budden before I snap, he better fasten it
// Or have his body bag get zipped
// The closest thing he's had to hits is smackin' bitches
// And don't make me have to give it back to Akademiks
// Say this shit is trash again, I'll have you twisted
// Like you had it when you thought you had me slippin' at the telly
// Even when I'm gettin' brain, you'll never catch me with a thot
// Lackin' with it, "he ain't spittin' like this on his last shit"
// Ho, you better go back and listen
// You know me better, thinkin' I'll slow or let up
// Call it trap 'cause it's a total setup
// Hopin' that you rappers fall in that
// Dre said, "Hold your head up!"—Kathy Griffin
// Stackin' ammunition, slap the clip in, cock it back on competition
// This is how I shot ahead (pew)—Gabby Giffords
// My attack is vicious, Jack the Ripper, back in business
// Tyler create nothin', I see why you called yourself a (faggot), bitch
// It's not just 'cause you lack attention
// It's because you worship D12's balls, you're sack-religious
// If you're gonna critique me
// You better at least be as good or better
// Get Earl the Hooded Sweater
// Whatever his name is to help you put together
// Some words, more than just two letters
// The fans waited for this moment like that feature
// When I stole the show (ha), sorry if I took forever (haha)

// ... Don't fall on my face (yeah)
// ... Don't fall on my faith, oh (I won't)
// ... Don't fall on my fate (line 'em up!)
// ... Don't fall on my faith, oh (ha)
// ... Don't fall on my fate (it's too easy)

// Just remember, I was here before you
// And I'll be here after you make your run-in for you
// Detractors, I might have to fuck Pitchfork with a corkscrew
// Just what the doctor ordered
// Revenge is the best medicine
// Increase the dose, from least to most
// And then tell the Grammys to go and fuck themselves
// They suck the blood from all the biggest artists like some leeches
// So they nominate 'em, get 'em there, get a name to MC the show
// Every parasite needs a host (haha)
// Then give Album of the Year to somebody that no one's ever even heard of
// All I know is I wrote every single word of
// Everything I ever murdered
// Time to separate the sheep from goats (yeah)
// And I got no faith in your writers, I don't believe in ghosts
// When rap needed it most, I was that wing and a prayer
// A beacon of hope, put a B-I-R-D in the air
// Somewhere some kid is bumpin' this while he lip-syncs in the mirror
// That's who I'm doin' it for, the rest I don't really even care
// But you would think I'm carryin' a Oxford dictionary in my pocket
// How I'm buryin' these artists
// On a scale of 'turnt' you're 'minus'
// Mine says 'very', yours says 'hardly'
// And what's scary is you probably can compare me to your car 'cause I'm just barely gettin' started (woo)
// And far as Lord Jamar, you better leave me the hell alone
// Or I'll show you an Elvis clone
// Walk up in this house you own, thrust my pelvic bone
// Use your telephone and go fetch me the remote
// Put my feet up and just make myself at home
// I belong here, clown, don't tell me 'bout the culture
// I inspired the Hopsins, the Logics, the Coles, the
// Seans, the K-Dots, the 5'9"s, and oh
// Brought the world 50 Cent, you did squat, piss and moan
// But I'm not gonna fall... bitch!

// ... It's too loud
// ... Can't hear it coming down the hallway stairs from the parking lot
// ... It's too loud
// ... Three's not a crowd all up in it
// ... Slow fire

#pragma GCC optimize ("Ofast,unroll-loops")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define fill(x, v) memset(x, v, sizeof(x))
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)

#define N 100005
#define mod 1000000007
#define M 26
#define bas 31
#define sqr(x) (x)*(x)
#define INF 1000000000

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> set_t;

#define trace(...) f(#__VA_ARGS__, __VA_ARGS__)

template<typename t> void f(const char* x, t&& val1){
    cout<<x<< " : "<<val1<<endl;
}

template<typename t1, typename... t2> void f(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    f(xd+1, val2...);
}

ll ar[N], ans[N], vis[N];
map<ll, ll > m;
inline ll kotaro(ll k, ll n){
    ll ans=0;
    deque<ll> dq;
    fill(vis, 0);
    FER(i,0,n){
        if(vis[ar[i]]) continue;
        vis[ar[i]]++;
        dq.push_back(ar[i]);
        if(sz(dq)>k){
            while(sz(dq)) vis[dq.front()]--, dq.pop_front();
            dq.push_back(ar[i]);
            vis[ar[i]]++;
            ans++;
        }
    }
    if(sz(dq)) ans++;
    return ans;
}
inline void solve(ll l, ll r, ll x, ll y, ll n){
    if(l>r) return;
    ll mid=(l+r)>>1;
    ll res=(x==y)? x : kotaro(mid, n);
    ans[mid]=res;
    solve(l, mid-1, res, y, n);
    solve(mid+1, r, x, res, n);
}

int main(){
    fastio;
    ll n; cin>>n;
    FER(i,0,n) cin>>ar[i];
    solve(1, n, 1, n, n);
    FER(i,1,n+1) cout<<ans[i]<<endl;
    return 0;
}


// Kotaro << Minoz << Hayama << Cohr3141592654

// Fall...

// You know, everybody's been tellin' me what they think about me for the last few months

// ... It's too loud
// Maybe it's time I tell 'em what I think about them
// ... Can't hear it coming down the hallway stairs from the parking lot
// ... It's too loud
// ... Three's not a crowd all up in it, slow fire

// ... Don't fall on my face
// ... Don't fall on my faith, oh
// ... Don't fall on my fate
// ... Don't fall on my faith, oh
// ... Don't fall on my fate
// ... Don't fall on my

// Gotta concentrate, against the clock I race
// Got no time to waste, I'm already late, I got a marathoner's pace
// Went from addict to a workaholic, word to Dr. Dre
// In that first marijuana tape-guess I got a chronic case (yeah)
// And I ain't just blowin' smoke, 'less it's in your momma's face
// I know this time Paul and Dre
// They won't tell me what not to say (nope)
// And though me and my party days
// Have all pretty much parted ways
// You'd swear to God I forgot I'm the guy that made "Not Afraid"
// One last time for Charlamagne
// If my response is late, it's just how long it takes
// To hit my fuckin' radar, I'm so far away
// These rappers are like Hunger Games
// One minute, they're mockin' Jay
// Next minute, they get their style from Migos or they copy Drake
// Maybe I just don't know when to turn around and walk away
// But all the hate, I call it "Walk on Water" gate
// I've had as much as I can tolerate
// I'm sick and tired of waitin', I done lost my patience
// I can take all of you motherfuckers on at once
// You wanted Shady? You got him!

// ... Don't fall on my face (yeah)
// ... Don't fall on my faith, oh
// ... Don't fall on my fate (line 'em up!)
// ... Don't fall on my faith, oh (rrr!)
// ... Don't fall on my fate (look)

// Somebody tell Budden before I snap, he better fasten it
// Or have his body bag get zipped
// The closest thing he's had to hits is smackin' bitches
// And don't make me have to give it back to Akademiks
// Say this shit is trash again, I'll have you twisted
// Like you had it when you thought you had me slippin' at the telly
// Even when I'm gettin' brain, you'll never catch me with a thot
// Lackin' with it, "he ain't spittin' like this on his last shit"
// Ho, you better go back and listen
// You know me better, thinkin' I'll slow or let up
// Call it trap 'cause it's a total setup
// Hopin' that you rappers fall in that
// Dre said, "Hold your head up!"—Kathy Griffin
// Stackin' ammunition, slap the clip in, cock it back on competition
// This is how I shot ahead (pew)—Gabby Giffords
// My attack is vicious, Jack the Ripper, back in business
// Tyler create nothin', I see why you called yourself a (faggot), bitch
// It's not just 'cause you lack attention
// It's because you worship D12's balls, you're sack-religious
// If you're gonna critique me
// You better at least be as good or better
// Get Earl the Hooded Sweater
// Whatever his name is to help you put together
// Some words, more than just two letters
// The fans waited for this moment like that feature
// When I stole the show (ha), sorry if I took forever (haha)

// ... Don't fall on my face (yeah)
// ... Don't fall on my faith, oh (I won't)
// ... Don't fall on my fate (line 'em up!)
// ... Don't fall on my faith, oh (ha)
// ... Don't fall on my fate (it's too easy)

// Just remember, I was here before you
// And I'll be here after you make your run-in for you
// Detractors, I might have to fuck Pitchfork with a corkscrew
// Just what the doctor ordered
// Revenge is the best medicine
// Increase the dose, from least to most
// And then tell the Grammys to go and fuck themselves
// They suck the blood from all the biggest artists like some leeches
// So they nominate 'em, get 'em there, get a name to MC the show
// Every parasite needs a host (haha)
// Then give Album of the Year to somebody that no one's ever even heard of
// All I know is I wrote every single word of
// Everything I ever murdered
// Time to separate the sheep from goats (yeah)
// And I got no faith in your writers, I don't believe in ghosts
// When rap needed it most, I was that wing and a prayer
// A beacon of hope, put a B-I-R-D in the air
// Somewhere some kid is bumpin' this while he lip-syncs in the mirror
// That's who I'm doin' it for, the rest I don't really even care
// But you would think I'm carryin' a Oxford dictionary in my pocket
// How I'm buryin' these artists
// On a scale of 'turnt' you're 'minus'
// Mine says 'very', yours says 'hardly'
// And what's scary is you probably can compare me to your car 'cause I'm just barely gettin' started (woo)
// And far as Lord Jamar, you better leave me the hell alone
// Or I'll show you an Elvis clone
// Walk up in this house you own, thrust my pelvic bone
// Use your telephone and go fetch me the remote
// Put my feet up and just make myself at home
// I belong here, clown, don't tell me 'bout the culture
// I inspired the Hopsins, the Logics, the Coles, the
// Seans, the K-Dots, the 5'9"s, and oh
// Brought the world 50 Cent, you did squat, piss and moan
// But I'm not gonna fall... bitch!

// ... It's too loud
// ... Can't hear it coming down the hallway stairs from the parking lot
// ... It's too loud
// ... Three's not a crowd all up in it
// ... Slow fire

#pragma GCC optimize ("Ofast,unroll-loops")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define fill(x, v) memset(x, v, sizeof(x))
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)

#define N 100005
#define mod 1000000007
#define M 26
#define bas 31
#define sqr(x) (x)*(x)
#define INF 1000000000

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> set_t;

#define trace(...) f(#__VA_ARGS__, __VA_ARGS__)

template<typename t> void f(const char* x, t&& val1){
    cout<<x<< " : "<<val1<<endl;
}

template<typename t1, typename... t2> void f(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    f(xd+1, val2...);
}

ll ar[N], ans[N];

inline ll kotaro(ll k, ll n){
    map<ll, ll> m;
    ll ans=0;
    FER(i,0,n) {
        m[ar[i]]++;
        if(sz(m)>k){
            ans++;
            m.clear();
            m[ar[i]]++;
        }
    }
    if(sz(m)) ans++;
    return ans;
}
inline void solve(ll l, ll r, ll x, ll y, ll n){
    if(l>r) return;
    ll mid=(l+r)>>1;
    ll res=(x==y)? x : kotaro(mid, n);
    ans[mid]=res;
    solve(l, mid-1, res, y, n);
    solve(mid+1, r, x, res, n);
}

int main(){
    fastio;
    ll n; cin>>n;
    FER(i,0,n) cin>>ar[i];
    solve(1, n, 1, n, n);
    FER(i,1,n+1) cout<<ans[i]<<endl;
    return 0;
}


// Kotaro << Minoz << Hayama << Cohr3141592654

// Fall...

// You know, everybody's been tellin' me what they think about me for the last few months

// ... It's too loud
// Maybe it's time I tell 'em what I think about them
// ... Can't hear it coming down the hallway stairs from the parking lot
// ... It's too loud
// ... Three's not a crowd all up in it, slow fire

// ... Don't fall on my face
// ... Don't fall on my faith, oh
// ... Don't fall on my fate
// ... Don't fall on my faith, oh
// ... Don't fall on my fate
// ... Don't fall on my

// Gotta concentrate, against the clock I race
// Got no time to waste, I'm already late, I got a marathoner's pace
// Went from addict to a workaholic, word to Dr. Dre
// In that first marijuana tape-guess I got a chronic case (yeah)
// And I ain't just blowin' smoke, 'less it's in your momma's face
// I know this time Paul and Dre
// They won't tell me what not to say (nope)
// And though me and my party days
// Have all pretty much parted ways
// You'd swear to God I forgot I'm the guy that made "Not Afraid"
// One last time for Charlamagne
// If my response is late, it's just how long it takes
// To hit my fuckin' radar, I'm so far away
// These rappers are like Hunger Games
// One minute, they're mockin' Jay
// Next minute, they get their style from Migos or they copy Drake
// Maybe I just don't know when to turn around and walk away
// But all the hate, I call it "Walk on Water" gate
// I've had as much as I can tolerate
// I'm sick and tired of waitin', I done lost my patience
// I can take all of you motherfuckers on at once
// You wanted Shady? You got him!

// ... Don't fall on my face (yeah)
// ... Don't fall on my faith, oh
// ... Don't fall on my fate (line 'em up!)
// ... Don't fall on my faith, oh (rrr!)
// ... Don't fall on my fate (look)

// Somebody tell Budden before I snap, he better fasten it
// Or have his body bag get zipped
// The closest thing he's had to hits is smackin' bitches
// And don't make me have to give it back to Akademiks
// Say this shit is trash again, I'll have you twisted
// Like you had it when you thought you had me slippin' at the telly
// Even when I'm gettin' brain, you'll never catch me with a thot
// Lackin' with it, "he ain't spittin' like this on his last shit"
// Ho, you better go back and listen
// You know me better, thinkin' I'll slow or let up
// Call it trap 'cause it's a total setup
// Hopin' that you rappers fall in that
// Dre said, "Hold your head up!"—Kathy Griffin
// Stackin' ammunition, slap the clip in, cock it back on competition
// This is how I shot ahead (pew)—Gabby Giffords
// My attack is vicious, Jack the Ripper, back in business
// Tyler create nothin', I see why you called yourself a (faggot), bitch
// It's not just 'cause you lack attention
// It's because you worship D12's balls, you're sack-religious
// If you're gonna critique me
// You better at least be as good or better
// Get Earl the Hooded Sweater
// Whatever his name is to help you put together
// Some words, more than just two letters
// The fans waited for this moment like that feature
// When I stole the show (ha), sorry if I took forever (haha)

// ... Don't fall on my face (yeah)
// ... Don't fall on my faith, oh (I won't)
// ... Don't fall on my fate (line 'em up!)
// ... Don't fall on my faith, oh (ha)
// ... Don't fall on my fate (it's too easy)

// Just remember, I was here before you
// And I'll be here after you make your run-in for you
// Detractors, I might have to fuck Pitchfork with a corkscrew
// Just what the doctor ordered
// Revenge is the best medicine
// Increase the dose, from least to most
// And then tell the Grammys to go and fuck themselves
// They suck the blood from all the biggest artists like some leeches
// So they nominate 'em, get 'em there, get a name to MC the show
// Every parasite needs a host (haha)
// Then give Album of the Year to somebody that no one's ever even heard of
// All I know is I wrote every single word of
// Everything I ever murdered
// Time to separate the sheep from goats (yeah)
// And I got no faith in your writers, I don't believe in ghosts
// When rap needed it most, I was that wing and a prayer
// A beacon of hope, put a B-I-R-D in the air
// Somewhere some kid is bumpin' this while he lip-syncs in the mirror
// That's who I'm doin' it for, the rest I don't really even care
// But you would think I'm carryin' a Oxford dictionary in my pocket
// How I'm buryin' these artists
// On a scale of 'turnt' you're 'minus'
// Mine says 'very', yours says 'hardly'
// And what's scary is you probably can compare me to your car 'cause I'm just barely gettin' started (woo)
// And far as Lord Jamar, you better leave me the hell alone
// Or I'll show you an Elvis clone
// Walk up in this house you own, thrust my pelvic bone
// Use your telephone and go fetch me the remote
// Put my feet up and just make myself at home
// I belong here, clown, don't tell me 'bout the culture
// I inspired the Hopsins, the Logics, the Coles, the
// Seans, the K-Dots, the 5'9"s, and oh
// Brought the world 50 Cent, you did squat, piss and moan
// But I'm not gonna fall... bitch!

// ... It's too loud
// ... Can't hear it coming down the hallway stairs from the parking lot
// ... It's too loud
// ... Three's not a crowd all up in it
// ... Slow fire

#pragma GCC optimize ("Ofast,unroll-loops")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define fill(x, v) memset(x, v, sizeof(x))
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)

#define N 100005
#define mod 1000000007
#define M 26
#define bas 31
#define sqr(x) (x)*(x)
#define INF 1000000000

using namespace std;
using namespace __gnu_pbds;

typedef int ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> set_t;

#define trace(...) f(#__VA_ARGS__, __VA_ARGS__)

template<typename t> void f(const char* x, t&& val1){
    cout<<x<< " : "<<val1<<endl;
}

template<typename t1, typename... t2> void f(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    f(xd+1, val2...);
}

ll ar[N], ans[N], vis[N];
map<ll, ll > m;
inline ll kotaro(ll k, ll n){
    ll ans=0;
    deque<ll> dq;
    fill(vis, 0);
    FER(i,0,n){
        if(vis[ar[i]]) continue;
        vis[ar[i]]++;
        dq.push_back(ar[i]);
        if(sz(dq)>k){
            while(sz(dq)) vis[dq.front()]--, dq.pop_front();
            dq.push_back(ar[i]);
            vis[ar[i]]++;
            ans++;
        }
    }
    if(sz(dq)) ans++;
    return ans;
}
inline void solve(ll l, ll r, ll x, ll y, ll n){
    if(l>r) return;
    ll mid=(l+r)>>1;
    ll res=(x==y)? x : kotaro(mid, n);
    ans[mid]=res;
    solve(l, mid-1, res, y, n);
    solve(mid+1, r, x, res, n);
}

int main(){
    fastio;
    ll n; cin>>n;
    FER(i,0,n) cin>>ar[i];
    solve(1, n, 1, n, n);
    FER(i,1,n+1) cout<<ans[i]<<endl;
    return 0;
}


// Kotaro << Minoz << Hayama << Cohr3141592654

// Fall...

// You know, everybody's been tellin' me what they think about me for the last few months

// ... It's too loud
// Maybe it's time I tell 'em what I think about them
// ... Can't hear it coming down the hallway stairs from the parking lot
// ... It's too loud
// ... Three's not a crowd all up in it, slow fire

// ... Don't fall on my face
// ... Don't fall on my faith, oh
// ... Don't fall on my fate
// ... Don't fall on my faith, oh
// ... Don't fall on my fate
// ... Don't fall on my

// Gotta concentrate, against the clock I race
// Got no time to waste, I'm already late, I got a marathoner's pace
// Went from addict to a workaholic, word to Dr. Dre
// In that first marijuana tape-guess I got a chronic case (yeah)
// And I ain't just blowin' smoke, 'less it's in your momma's face
// I know this time Paul and Dre
// They won't tell me what not to say (nope)
// And though me and my party days
// Have all pretty much parted ways
// You'd swear to God I forgot I'm the guy that made "Not Afraid"
// One last time for Charlamagne
// If my response is late, it's just how long it takes
// To hit my fuckin' radar, I'm so far away
// These rappers are like Hunger Games
// One minute, they're mockin' Jay
// Next minute, they get their style from Migos or they copy Drake
// Maybe I just don't know when to turn around and walk away
// But all the hate, I call it "Walk on Water" gate
// I've had as much as I can tolerate
// I'm sick and tired of waitin', I done lost my patience
// I can take all of you motherfuckers on at once
// You wanted Shady? You got him!

// ... Don't fall on my face (yeah)
// ... Don't fall on my faith, oh
// ... Don't fall on my fate (line 'em up!)
// ... Don't fall on my faith, oh (rrr!)
// ... Don't fall on my fate (look)

// Somebody tell Budden before I snap, he better fasten it
// Or have his body bag get zipped
// The closest thing he's had to hits is smackin' bitches
// And don't make me have to give it back to Akademiks
// Say this shit is trash again, I'll have you twisted
// Like you had it when you thought you had me slippin' at the telly
// Even when I'm gettin' brain, you'll never catch me with a thot
// Lackin' with it, "he ain't spittin' like this on his last shit"
// Ho, you better go back and listen
// You know me better, thinkin' I'll slow or let up
// Call it trap 'cause it's a total setup
// Hopin' that you rappers fall in that
// Dre said, "Hold your head up!"—Kathy Griffin
// Stackin' ammunition, slap the clip in, cock it back on competition
// This is how I shot ahead (pew)—Gabby Giffords
// My attack is vicious, Jack the Ripper, back in business
// Tyler create nothin', I see why you called yourself a (faggot), bitch
// It's not just 'cause you lack attention
// It's because you worship D12's balls, you're sack-religious
// If you're gonna critique me
// You better at least be as good or better
// Get Earl the Hooded Sweater
// Whatever his name is to help you put together
// Some words, more than just two letters
// The fans waited for this moment like that feature
// When I stole the show (ha), sorry if I took forever (haha)

// ... Don't fall on my face (yeah)
// ... Don't fall on my faith, oh (I won't)
// ... Don't fall on my fate (line 'em up!)
// ... Don't fall on my faith, oh (ha)
// ... Don't fall on my fate (it's too easy)

// Just remember, I was here before you
// And I'll be here after you make your run-in for you
// Detractors, I might have to fuck Pitchfork with a corkscrew
// Just what the doctor ordered
// Revenge is the best medicine
// Increase the dose, from least to most
// And then tell the Grammys to go and fuck themselves
// They suck the blood from all the biggest artists like some leeches
// So they nominate 'em, get 'em there, get a name to MC the show
// Every parasite needs a host (haha)
// Then give Album of the Year to somebody that no one's ever even heard of
// All I know is I wrote every single word of
// Everything I ever murdered
// Time to separate the sheep from goats (yeah)
// And I got no faith in your writers, I don't believe in ghosts
// When rap needed it most, I was that wing and a prayer
// A beacon of hope, put a B-I-R-D in the air
// Somewhere some kid is bumpin' this while he lip-syncs in the mirror
// That's who I'm doin' it for, the rest I don't really even care
// But you would think I'm carryin' a Oxford dictionary in my pocket
// How I'm buryin' these artists
// On a scale of 'turnt' you're 'minus'
// Mine says 'very', yours says 'hardly'
// And what's scary is you probably can compare me to your car 'cause I'm just barely gettin' started (woo)
// And far as Lord Jamar, you better leave me the hell alone
// Or I'll show you an Elvis clone
// Walk up in this house you own, thrust my pelvic bone
// Use your telephone and go fetch me the remote
// Put my feet up and just make myself at home
// I belong here, clown, don't tell me 'bout the culture
// I inspired the Hopsins, the Logics, the Coles, the
// Seans, the K-Dots, the 5'9"s, and oh
// Brought the world 50 Cent, you did squat, piss and moan
// But I'm not gonna fall... bitch!

// ... It's too loud
// ... Can't hear it coming down the hallway stairs from the parking lot
// ... It's too loud
// ... Three's not a crowd all up in it
// ... Slow fire

#pragma GCC optimize ("Ofast,unroll-loops")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define fill(x, v) memset(x, v, sizeof(x))
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)

#define N 100005
#define mod 1000000007
#define M 26
#define bas 31
#define sqr(x) (x)*(x)
#define INF 1000000000

using namespace std;
using namespace __gnu_pbds;

typedef int ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> set_t;

#define trace(...) f(#__VA_ARGS__, __VA_ARGS__)

template<typename t> void f(const char* x, t&& val1){
    cout<<x<< " : "<<val1<<endl;
}

template<typename t1, typename... t2> void f(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    f(xd+1, val2...);
}

ll ar[N], ans[N];
map<ll, ll > m;
inline ll kotaro(ll k, ll n){
    m.clear();
    ll ans=0;
    FER(i,0,n) {
        m[ar[i]]++;
        if(sz(m)>k){
            ans++;
            m.clear();
            m[ar[i]]++;
        }
    }
    if(sz(m)) ans++;
    return ans;
}
inline void solve(ll l, ll r, ll x, ll y, ll n){
    if(l>r) return;
    ll mid=(l+r)>>1;
    ll res=(x==y)? x : kotaro(mid, n);
    ans[mid]=res;
    solve(l, mid-1, res, y, n);
    solve(mid+1, r, x, res, n);
}

int main(){
    fastio;
    ll n; cin>>n;
    FER(i,0,n) cin>>ar[i];
    solve(1, n, 1, n, n);
    FER(i,1,n+1) cout<<ans[i]<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;

const int maxn = 1e5 + 10;
const int maxl = 40;

int newint = 1;

int k;

int seg[maxn * maxl], lc[maxn * maxl], rc[maxn * maxl];

int get(int id, int L, int R, int l, int r){
	if (L == l and R == r){
		if (seg[id] <= k){
			 k -= seg[id];
			 return -1;
		}
		if (L + 1 == R){
			k -= seg[id];
			return L;
		}
		int mid = (L + R) >> 1;
		if (seg[lc[id]] > k)
			return get(lc[id], L, mid, l, mid);
		k -= seg[lc[id]];
		return get(rc[id], mid, R, mid, r);
	}
	int mid = (L + R) >> 1;
	if (l < mid){
		int ret = get(lc[id], L, mid, l, min(mid, r));
		if (k < 0)
			return ret;
	}
	return get(rc[id], mid, R, max(l, mid), r);
}

int add(int id, int L, int R, int idx, int val){
	int node = newint ++;
	seg[node] = seg[id] + val;
	if (L + 1 == R)
		return node;
	int mid = (L + R) >> 1;
	lc[node] = lc[id], rc[node] = rc[id];
	if (idx < mid)
		lc[node] = add(lc[id], L, mid, idx, val);
	else
		rc[node] = add(rc[id], mid, R, idx, val);
	return node;
}

int a[maxn], last[maxn], root[maxn];

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];

	memset(last, -1, sizeof last);
	for (int i = n - 1; i >= 0; i--){
		root[i] = root[i + 1];
		if (last[a[i]] != -1)
			root[i] = add(root[i], 0, n, last[a[i]], -1);
		root[i] = add(root[i], 0, n, i, +1);
		last[a[i]] = i;
	}
	for (int i = 1; i <= n; i++){
		int l = 0, cnt = 0;
		while (l < n){
			cnt ++;
			k = i;
			l = get(root[l], 0, n, l, n);
			if (k >= 0)
				break;
		}
		cout << cnt << " ";
	}
	cout << endl;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;

const int maxn = 1e5 + 10;
const int maxl = 20;

int newint = 1;

int k;

int seg[maxn * maxl], lc[maxn * maxl], rc[maxn * maxl];

int get(int id, int L, int R, int l, int r){
	if (L == l and R == r){
		if (seg[id] <= k){
			 k -= seg[id];
			 return -1;
		}
		if (L + 1 == R){
			k -= seg[id];
			return L;
		}
		int mid = (L + R) >> 1;
		if (seg[lc[id]] > k)
			return get(lc[id], L, mid, l, mid);
		k -= seg[lc[id]];
		return get(rc[id], mid, R, mid, r);
	}
	int mid = (L + R) >> 1;
	if (l < mid){
		int ret = get(lc[id], L, mid, l, min(mid, r));
		if (k < 0)
			return ret;
	}
	return get(rc[id], mid, R, max(l, mid), r);
}

int add(int id, int L, int R, int idx, int val){
	int node = newint ++;
	seg[node] = seg[id] + val;
	if (L + 1 == R)
		return node;
	int mid = (L + R) >> 1;
	lc[node] = lc[id], rc[node] = rc[id];
	if (idx < mid)
		lc[node] = add(lc[id], L, mid, idx, val);
	else
		rc[node] = add(rc[id], mid, R, idx, val);
	return node;
}

int a[maxn], last[maxn], root[maxn];

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];

	memset(last, -1, sizeof last);
	for (int i = n - 1; i >= 0; i--){
		root[i] = root[i + 1];
		if (last[a[i]] != -1)
			root[i] = add(root[i], 0, n, last[a[i]], -1);
		root[i] = add(root[i], 0, n, i, +1);
		last[a[i]] = i;
	}
	for (int i = 1; i <= n; i++){
		int l = 0, cnt = 0;
		while (l < n){
			cnt ++;
			k = i;
			l = get(root[l], 0, n, l, n);
			if (k >= 0)
				break;
		}
		cout << cnt << " ";
	}
	cout << endl;
}


/*
ID: dorijan1
TASK: tu napisi ime zadatka molim te molim te ali samo ako si na usaco training
LANG: C++11
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define rand rund
#define pb push_back

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
const int MOD=1000000007;
const int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w)
{
	cout<<w.size()<<endl;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<endl;
}

ll raand()
{
	ll a=rand();
	a*=RAND_MAX;
	a+=rand();
    return a;
}

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

ll gcd(ll a,ll b)
{
	if (b==0) return a;
	return gcd(b,a%b);
}

ll lcm(ll a,ll b)
{
	return a/gcd(a,b)*b;
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

int sub(int a,int b)
{
	return (a-b+MOD)%MOD;
}

int add(int a,int b)
{
	return (a+b)%MOD;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

ll has(string x)
{
	ll h1=0,h2=0;
	x=to_lower(x);
	for (char a: x)
	{
		h1*=bases[0];
		h1+=a-'a';
		h1%=bases[3];
		h2*=bases[1];
		h2+=a-'a';
		h2%=bases[4];
	}
	return h1*(MOD+13893829)+h2;
}

const int N=300010;
int n,dp[N],h[N];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
gp_hash_table<int,int> g;

int solve(int k)
{
	if (dp[k]) return dp[k];
	g.clear();
	int nu=1;
	for (int i=0;i<n;++i)
	{
		++g[h[i]];
		if (g.size()>k)
		{
			g.clear();
			++g[h[i]];
			++nu;
		}
	}
	return dp[k]=nu;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back((raand()%MOD+13893829)%MOD);
	cin>>n;
	for (int i=0;i<n;++i) cin>>h[i];
	for (int i=1;i<=n;++i)
	{
		if (dp[i]) continue;
		solve(i);
		int l=i,r=n;
		while (l<r)
		{
			int mid=(l+r+1)/2;
			if (solve(mid)==dp[i]) l=mid;
			else r=mid-1;
		}
		for (int j=i;j<=l;++j) dp[j]=dp[i];
	}
	for (int i=1;i<=n;++i) cout<<dp[i]<<' ';
}


/*
ID: dorijan1
TASK: tu napisi ime zadatka molim te molim te ali samo ako si na usaco training
LANG: C++11
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define rand rund
#define pb push_back

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
const int MOD=1000000007;
const int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w)
{
	cout<<w.size()<<endl;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<endl;
}

ll raand()
{
	ll a=rand();
	a*=RAND_MAX;
	a+=rand();
    return a;
}

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

ll gcd(ll a,ll b)
{
	if (b==0) return a;
	return gcd(b,a%b);
}

ll lcm(ll a,ll b)
{
	return a/gcd(a,b)*b;
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

int sub(int a,int b)
{
	return (a-b+MOD)%MOD;
}

int add(int a,int b)
{
	return (a+b)%MOD;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

ll has(string x)
{
	ll h1=0,h2=0;
	x=to_lower(x);
	for (char a: x)
	{
		h1*=bases[0];
		h1+=a-'a';
		h1%=bases[3];
		h2*=bases[1];
		h2+=a-'a';
		h2%=bases[4];
	}
	return h1*(MOD+13893829)+h2;
}

const int N=300010;
int n,dp[N],h[N];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
bitset<100000> b;
vector<int> v;

int solve(int k)
{
	if (dp[k]) return dp[k];
	for (auto z: v) b[z]=0;
	v.clear();
	int nu=1,x=0;
	for (int i=0;i<n;++i)
	{
		if (!b[h[i]])
		{
			if (x==k)
			{
				x=0;
				for (auto z: v) b[z]=0;
				v.clear();
				++nu;
			}
			b[h[i]]=1;
			v.push_back(h[i]);
			++x;
		}
	}
	return dp[k]=nu;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back((raand()%MOD+13893829)%MOD);
	cin>>n;
	for (int i=0;i<n;++i) cin>>h[i],--h[i];
	for (int i=1;i<=n;++i)
	{
		if (dp[i]) continue;
		solve(i);
		int l=i,r=n;
		while (l<r)
		{
			int mid=(l+r+1)/2;
			if (solve(mid)==dp[i]) l=mid;
			else r=mid-1;
		}
		for (int j=i;j<=l;++j) dp[j]=dp[i];
	}
	for (int i=1;i<=n;++i) cout<<dp[i]<<' ';
}


/*
ID: dorijan1
TASK: tu napisi ime zadatka molim te molim te ali samo ako si na usaco training
LANG: C++11
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define rand rund
#define pb push_back

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
const int MOD=1000000007;
const int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w)
{
	cout<<w.size()<<endl;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<endl;
}

ll raand()
{
	ll a=rand();
	a*=RAND_MAX;
	a+=rand();
    return a;
}

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

ll gcd(ll a,ll b)
{
	if (b==0) return a;
	return gcd(b,a%b);
}

ll lcm(ll a,ll b)
{
	return a/gcd(a,b)*b;
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

int sub(int a,int b)
{
	return (a-b+MOD)%MOD;
}

int add(int a,int b)
{
	return (a+b)%MOD;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

ll has(string x)
{
	ll h1=0,h2=0;
	x=to_lower(x);
	for (char a: x)
	{
		h1*=bases[0];
		h1+=a-'a';
		h1%=bases[3];
		h2*=bases[1];
		h2+=a-'a';
		h2%=bases[4];
	}
	return h1*(MOD+13893829)+h2;
}

const int N=300010;
int n,dp[N],h[N];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
bitset<100000> b;
vector<int> v;

int solve(int k)
{
	if (dp[k]) return dp[k];
	for (auto z: v) b[z]=0;
	v.clear();
	int nu=1,x=0;
	for (int i=0;i<n;++i)
	{
		if (!b[h[i]])
		{
			if (x==k)
			{
				x=0;
				for (auto z: v) b[z]=0;
				v.clear();
				++nu;
			}
			b[h[i]]=1;
			v.push_back(h[i]);
			++x;
		}
	}
	return dp[k]=nu;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back((raand()%MOD+13893829)%MOD);
	cin>>n;
	for (int i=0;i<n;++i) cin>>h[i],--h[i];
	for (int i=1;i<=n;++i)
	{
		if (dp[i]) continue;
		solve(i);
		if (solve(i+1)==solve(i))
		{
			int l=i,r=n;
			while (l<r)
			{
				int mid=(l+r+1)/2;
				if (solve(mid)==dp[i]) l=mid;
				else r=mid-1;
			}
			for (int j=i;j<=l;++j) dp[j]=dp[i];
		}
	}
	for (int i=1;i<=n;++i) cout<<dp[i]<<' ';
}


#include<bits/stdc++.h>

using namespace std;

const int maxn = 2e5;
int RM[maxn];
int last[maxn];
int arr[maxn];
int n , m , i , x , y , z , k;
deque < int > pos[maxn];
struct node{
    int cnt;
    node* left , *right;
    node(){
        cnt = 0; left = NULL; right = NULL;
    }
    node(node* _left , node* _right , int _cnt){
        left = _left ; right = _right; cnt = _cnt;
    }
};
node* roots[maxn+1];

void build(node* root , int l , int r){
    if(l == r){
        root->cnt = 0;
        return;
    }
    int mid = (l + r)/2;
    root->left = new node(NULL,NULL,0);
    root->right = new node(NULL,NULL,0);
    build(root->left, l , mid);
    build(root->right , mid + 1 , r);
    root->cnt = root->left->cnt + root->right->cnt;
}

void upgrade(node* prev , node* cur , int l , int r , int idx , int value){
    if(l == r){
        cur->cnt = value;
        return;
    }
    int mid = (l + r)/2;
    if(idx <= mid){
        cur->right = prev->right;
        cur->left = new node(NULL,NULL,0);
        upgrade(prev->left,cur->left,l,mid,idx,value);
    }
    else{
        cur->left = prev->left;
        cur->right = new node(NULL,NULL,0);
        upgrade(prev->right,cur->right,mid+1,r,idx,value);
    }
    cur->cnt = cur->left->cnt + cur->right->cnt;
}

int query(node* root , int left , int right , int k){
    //cout << left << " " << right << " " << k << endl;
    if(root->cnt < k)return 0;
    if(left == right)return left;
    int mid = (left + right)/2;
    if(root->right->cnt <= k){
        return query(root->left , left , mid , k-root->right->cnt);
    }
    else return query(root->right , mid + 1 , right , k);
}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin >> n; k = 1;
    for(int i = 1; i<=n; i++){
        cin >> arr[i];
    }
    node* root = new node();
    roots[0] = root;
    build(root,0,n);
    int cur = 1;

    for(int i = 1; i<=n; i++){
        roots[cur] = new node(NULL,NULL,0);
        if((int)pos[arr[i]].size() < k){
            upgrade(roots[cur-1] , roots[cur] , 0 , n , i , 1);
            RM[i] = cur;
        }
        else{
            upgrade(roots[cur-1] , roots[cur] , 0 , n , i , 1);
            cur++;
            roots[cur] = new node(NULL,NULL,0);
            upgrade(roots[cur-1] , roots[cur] , 0 , n , pos[arr[i]].back() , 0);
            RM[i] = cur;
            pos[arr[i]].pop_back();
        }
        cur++;
        pos[arr[i]].push_front(i);
    }

    for(int i = 1; i<=n; i++){
        int lst = n , ret = 0;
        while(lst >= 1){
            ret++;
            lst = query(roots[RM[lst]] , 0 , n , i);
        }
        cout << ret << " ";
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

const int maxn = 2e5;
int RM[maxn];
int last[maxn];
int arr[maxn];
int n , m , i , x , y , z , k;
deque < int > pos[maxn];
struct node{
    int cnt;
    node* left , *right;
    node(){
        cnt = 0; left = NULL; right = NULL;
    }
    node(node* _left , node* _right , int _cnt){
        left = _left ; right = _right; cnt = _cnt;
    }
};
node* roots[maxn+1];

void build(node* root , int l , int r){
    if(l == r){
        root->cnt = 0;
        return;
    }
    int mid = (l + r)/2;
    root->left = new node(NULL,NULL,0);
    root->right = new node(NULL,NULL,0);
    build(root->left, l , mid);
    build(root->right , mid + 1 , r);
    root->cnt = root->left->cnt + root->right->cnt;
}

void upgrade(node* prev , node* cur , int l , int r , int idx , int value){
    if(l == r){
        cur->cnt = value;
        return;
    }
    int mid = (l + r)/2;
    if(idx <= mid){
        cur->right = prev->right;
        cur->left = new node(NULL,NULL,0);
        upgrade(prev->left,cur->left,l,mid,idx,value);
    }
    else{
        cur->left = prev->left;
        cur->right = new node(NULL,NULL,0);
        upgrade(prev->right,cur->right,mid+1,r,idx,value);
    }
    cur->cnt = cur->left->cnt + cur->right->cnt;
}

int query(node* root , int left , int right , int query_left , int query_right){

    if(query_right < left || right < query_left)
       return 0;

    if(query_left <= left && right <= query_right)
        return root->cnt;
    int mid = (left + right)/2;
    int l = query(root->left , left , mid , query_left, query_right);
    int r = query(root->right, mid+1, right , query_left , query_right);
    return (l + r);
}

int binary(int l , int k){
    int lo = l , hi = n;
    int ans = l;
    while(lo <= hi){
        int mid = (lo + hi)/2;
        if(query(roots[RM[mid]] , 0 , n , l , mid) <= k){
            ans = mid;
            lo = mid + 1;
        }
        else hi = mid - 1;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin >> n; k = 1;
    for(int i = 1; i<=n; i++){
        cin >> arr[i];
    }
    node* root = new node();
    roots[0] = root;
    build(root,0,n);
    int cur = 1;

    for(int i = 1; i<=n; i++){
        roots[cur] = new node(NULL,NULL,0);
        if((int)pos[arr[i]].size() < k){
            upgrade(roots[cur-1] , roots[cur] , 0 , n , i , 1);
            RM[i] = cur;
        }
        else{
            upgrade(roots[cur-1] , roots[cur] , 0 , n , i , 1);
            cur++;
            roots[cur] = new node(NULL,NULL,0);
            upgrade(roots[cur-1] , roots[cur] , 0 , n , pos[arr[i]].back() , 0);
            RM[i] = cur;
            pos[arr[i]].pop_back();
        }
        cur++;
        pos[arr[i]].push_front(i);
    }

    for(int i = 1; i<=n; i++){
        int lst = 1 , ret = 0;
        while(lst <= n){
            ret++;
            lst = binary(lst , i) + 1;
            //cout << lst << " " << i << endl;
        }
        cout << ret << " ";
    }
    return 0;
}


///  http://codeforces.com/contest/548/problem/D
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int,int>
#define V(x) vector<x>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back

#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend());

#define FORLL(i,a,n) for(long long int i=(a); i<(n); ++i)
#define FORDLL(i,a,n) for(long long int i=(a);i>=(n);--i)
#define FOR(c, f, t) for(int c=f;c<t;c++)
#define FORD(c, f, t) for(int c=f;c>=t;c--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define mem(a,k) memset(a,k,sizeof(a))
#define M 1000000007
#define isactive(x,k) (x&(1<<k))

#define SIN(x) cin>>x
#define DIN(x, y) cin>>x>>y
#define TIN(x, y, z) cin>>x>>y>>z
#define FIN(w, x, y, z) cin>>w>>x>>y>>z

#define SOP(x) cout<<x<<" "
#define DOP(x, y) cout<<x<<" "<<y<<"\n"
#define TOP(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define FOP(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"

#define PRESENT(container, x) container.find(x) != container.end()
#define fi first
#define se second
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define MAX INT_MAX
#define MIN INT_MIN
using namespace std;
/*
#define cin fin
#define cout fout

ifstream fin("input.txt");
ofstream fout("output.txt");
*/
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
/*inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}*/
int partial[200005];
map<int,int> power;
stack<pii> store;
int ans[200005];
vector<pii> lefty(200005),righty(200005);  /// value,power
int main()
{
    int n,a;
    SIN(n);

    FOR(i,0,n){
    SIN(a);
    lefty[i].fi=a;
    lefty[i].se=0;
    righty[i].se=0;
    righty[i].fi=a;
    }

     ///  value,index
    store.push({lefty[0].fi,0});
    int ind=1,cnt=0;
    while(!store.empty() && ind<n){
        if(lefty[ind].fi <= store.top().fi){
            while(!store.empty() && store.top().fi >= lefty[ind].fi ){
                lefty[ind].se+=(lefty[store.top().se].se+1);
                store.pop();
            }
            store.push({lefty[ind].fi,ind});
        }
        else
            store.push({lefty[ind].fi,ind});
        ind++;
    }
    while(!store.empty()){
        store.pop();
    }
    store.push({lefty[n-1].fi,n-1});
    ind=n-2;
    while(!store.empty() && ind>=0){
        if(lefty[ind].fi <= store.top().fi){
            while(!store.empty() && store.top().fi >= lefty[ind].fi){
                righty[ind].se+=(righty[store.top().se].se+1);
                store.pop();
            }
           // cout<<lefty[ind].fi<<" "<<righty[ind].se<<endl;
            store.push({lefty[ind].fi,ind});
        }
        else
        store.push({lefty[ind].fi,ind});
        ind--;
    }
    /*FOR(i,0,n)
    DOP(lefty[i].fi,lefty[i].se);
    cout<<endl<<endl;
    FOR(i,0,n)
    DOP(righty[i].fi,righty[i].se);
    cout<<endl<<endl;*/
    int val;
    FOR(i,0,n){
        val=lefty[i].se+righty[i].se+1;
        partial[val]=max(partial[val],lefty[i].fi);
    }
    for(int i=n-1;i>=0;i--){
        if(!partial[i])
            partial[i]=partial[i+1];
    }
    FOR(i,1,n+1)
        SOP(partial[i]);
    /*map<int,int> :: reverse_iterator it;
    it=power.rbegin();
    cnt=0;
    while(it!=power.rend() && cnt !=n){
       // DOP(it->fi,it->se);
        int len=it->second;
        while(len){
            if(!ans[len]){
            ans[len]=it->first;
            cnt++;
            }
            len--;
        }
        it++;
    }
    FOR(i,1,n+1)
    SOP(ans[i]);*/
    return 0;
}


///  http://codeforces.com/contest/548/problem/D
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int,int>
#define V(x) vector<x>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back

#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend());

#define FORLL(i,a,n) for(long long int i=(a); i<(n); ++i)
#define FORDLL(i,a,n) for(long long int i=(a);i>=(n);--i)
#define FOR(c, f, t) for(int c=f;c<t;c++)
#define FORD(c, f, t) for(int c=f;c>=t;c--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define mem(a,k) memset(a,k,sizeof(a))
#define M 1000000007
#define isactive(x,k) (x&(1<<k))

#define SIN(x) cin>>x
#define DIN(x, y) cin>>x>>y
#define TIN(x, y, z) cin>>x>>y>>z
#define FIN(w, x, y, z) cin>>w>>x>>y>>z

#define SOP(x) cout<<x<<" "
#define DOP(x, y) cout<<x<<" "<<y<<"\n"
#define TOP(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define FOP(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"

#define PRESENT(container, x) container.find(x) != container.end()
#define fi first
#define se second
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define MAX INT_MAX
#define MIN INT_MIN
using namespace std;
/*
#define cin fin
#define cout fout

ifstream fin("input.txt");
ofstream fout("output.txt");
*/
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
/*inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}*/
int inp[200005];
map<int,int> power;
int ans[200005];
int main()
{
    int n;
    SIN(n);
    vector<pii> left(n),right(n);  /// value,power
    FOR(i,0,n){
    SIN(inp[i]);
    left[i].fi=inp[i];
    left[i].se=0;
    right[i].se=0;
    right[i].fi=inp[i];
    }

    stack<pii> store; ///  value,index
    store.push({inp[0],0});
    int ind=1,cnt=0;
    while(!store.empty() && ind<n){
        if(inp[ind] <= store.top().fi){
            while(!store.empty() && store.top().fi >= inp[ind] ){
                left[ind].se+=(left[store.top().se].se+1);
                store.pop();
            }
            store.push({inp[ind],ind});
        }
        else
            store.push({inp[ind],ind});
        ind++;
    }
    while(!store.empty()){
        store.pop();
    }
    store.push({inp[n-1],n-1});
    ind=n-2;
    while(!store.empty() && ind>=0){
        if(inp[ind] <= store.top().fi){

            while(!store.empty() && store.top().fi >= inp[ind]){
                right[ind].se+=(right[store.top().se].se+1);
                store.pop();
            }
           // cout<<inp[ind]<<" "<<right[ind].se<<endl;
            store.push({inp[ind],ind});
        }
        else
        store.push({inp[ind],ind});
        ind--;
    }
    /*FOR(i,0,n)
    DOP(left[i].fi,left[i].se);
    cout<<endl<<endl;
    FOR(i,0,n)
    DOP(right[i].fi,right[i].se);
    cout<<endl<<endl;*/
    FOR(i,0,n)
        power[left[i].fi]=max(power[left[i].fi],left[i].se+right[i].se+1);
    map<int,int> :: reverse_iterator it;
    it=power.rbegin();
    cnt=0;
    while(it!=power.rend() && cnt !=n){
       // DOP(it->fi,it->se);
        int len=it->second;
        while(len){
            if(!ans[len]){
            ans[len]=it->first;
            cnt++;
            }
            len--;
        }
        it++;
    }
    FOR(i,1,n+1)
    SOP(ans[i]);
    return 0;
}


///  http://codeforces.com/contest/548/problem/D
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int,int>
#define V(x) vector<x>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back

#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend());

#define FORLL(i,a,n) for(long long int i=(a); i<(n); ++i)
#define FORDLL(i,a,n) for(long long int i=(a);i>=(n);--i)
#define FOR(c, f, t) for(int c=f;c<t;c++)
#define FORD(c, f, t) for(int c=f;c>=t;c--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define mem(a,k) memset(a,k,sizeof(a))
#define M 1000000007
#define isactive(x,k) (x&(1<<k))

#define SIN(x) cin>>x
#define DIN(x, y) cin>>x>>y
#define TIN(x, y, z) cin>>x>>y>>z
#define FIN(w, x, y, z) cin>>w>>x>>y>>z

#define SOP(x) cout<<x<<" "
#define DOP(x, y) cout<<x<<" "<<y<<"\n"
#define TOP(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define FOP(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"

#define PRESENT(container, x) container.find(x) != container.end()
#define fi first
#define se second
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define MAX INT_MAX
#define MIN INT_MIN
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
int inp[200005];
map<int,int> power;
int ans[200005];
int main()
{
    int n;
    SIN(n);
    vector<pii> left(n),right(n);  /// value,power
    FOR(i,0,n){
    SIN(inp[i]);
    left[i].fi=inp[i];
    left[i].se=0;
    right[i].se=0;
    right[i].fi=inp[i];
    }

    stack<pii> store; ///  value,index
    store.push({inp[0],0});
    int ind=1,cnt=0;
    while(!store.empty() && ind<n){
        if(inp[ind] < store.top().fi){
            while(!store.empty() && store.top().fi >= inp[ind] ){
                left[ind].se+=(left[store.top().se].se+1);
                store.pop();
            }
            store.push({inp[ind],ind});
        }
        else
            store.push({inp[ind],ind});
        ind++;
    }
    while(!store.empty()){
        store.pop();
    }
    store.push({inp[n-1],n-1});
    ind=n-2;
    while(!store.empty() && ind>0){
        if(inp[ind] < store.top().fi){

            while(!store.empty() && store.top().fi >= inp[ind]){
                right[ind].se+=(right[store.top().se].se+1);
                store.pop();
            }
            store.push({inp[ind],ind});
        }
        else
        store.push({inp[ind],ind});
        ind--;
    }
    FOR(i,0,n)
        power[left[i].fi]=max(power[left[i].fi],left[i].se+right[i].se+1);
    map<int,int> :: reverse_iterator it;
    it=power.rbegin();
    cnt=0;
    while(it!=power.rend() && cnt !=n){
        int len=it->second;
        while(len){
            if(!ans[len]){
            ans[len]=it->first;
            cnt++;
            }
            len--;
        }
        it++;
    }
    FOR(i,1,n+1)
    SOP(ans[i]);
    return 0;
}


///  http://codeforces.com/contest/548/problem/D
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int,int>
#define V(x) vector<x>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back

#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend());

#define FORLL(i,a,n) for(long long int i=(a); i<(n); ++i)
#define FORDLL(i,a,n) for(long long int i=(a);i>=(n);--i)
#define FOR(c, f, t) for(int c=f;c<t;c++)
#define FORD(c, f, t) for(int c=f;c>=t;c--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define mem(a,k) memset(a,k,sizeof(a))
#define M 1000000007
#define isactive(x,k) (x&(1<<k))

#define SIN(x) cin>>x
#define DIN(x, y) cin>>x>>y
#define TIN(x, y, z) cin>>x>>y>>z
#define FIN(w, x, y, z) cin>>w>>x>>y>>z

#define SOP(x) cout<<x<<" "
#define DOP(x, y) cout<<x<<" "<<y<<"\n"
#define TOP(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define FOP(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"

#define PRESENT(container, x) container.find(x) != container.end()
#define fi first
#define se second
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define MAX INT_MAX
#define MIN INT_MIN
using namespace std;
/*
#define cin fin
#define cout fout

ifstream fin("input.txt");
ofstream fout("output.txt");
*/
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
/*inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}*/
int partial[200005];
map<int,int> power;
stack<pii> store;
int ans[200005];
vector<pii> lefty(200005),righty(200005);  /// value,power
int main()
{
    int n,a;
    SIN(n);

    FOR(i,0,n){
    SIN(a);
    lefty[i].fi=a;
    lefty[i].se=0;
    righty[i].se=0;
    righty[i].fi=a;
    }

     ///  value,index
    store.push({lefty[0].fi,0});
    int ind=1,cnt=0;
    while(!store.empty() && ind<n){
        if(lefty[ind].fi <= store.top().fi){
            while(!store.empty() && store.top().fi >= lefty[ind].fi ){
                lefty[ind].se+=(lefty[store.top().se].se+1);
                store.pop();
            }
            store.push({lefty[ind].fi,ind});
        }
        else
            store.push({lefty[ind].fi,ind});
        ind++;
    }
    while(!store.empty()){
        store.pop();
    }
    store.push({lefty[n-1].fi,n-1});
    ind=n-2;
    while(!store.empty() && ind>=0){
        if(lefty[ind].fi <= store.top().fi){
            while(!store.empty() && store.top().fi >= lefty[ind].fi){
                righty[ind].se+=(righty[store.top().se].se+1);
                store.pop();
            }
           // cout<<lefty[ind].fi<<" "<<righty[ind].se<<endl;
            store.push({lefty[ind].fi,ind});
        }
        else
        store.push({lefty[ind].fi,ind});
        ind--;
    }
    /*FOR(i,0,n)
    DOP(lefty[i].fi,lefty[i].se);
    cout<<endl<<endl;
    FOR(i,0,n)
    DOP(righty[i].fi,righty[i].se);
    cout<<endl<<endl;*/
    int val;
    FOR(i,0,n){
        val=lefty[i].se+righty[i].se+1;
        partial[val]=max(partial[val],lefty[i].fi);
    }
    for(int i=n-1;i>=0;i--){
        if(partial[i] < partial[i+1])
            partial[i]=partial[i+1];
    }
    FOR(i,1,n+1)
        SOP(partial[i]);
    /*map<int,int> :: reverse_iterator it;
    it=power.rbegin();
    cnt=0;
    while(it!=power.rend() && cnt !=n){
       // DOP(it->fi,it->se);
        int len=it->second;
        while(len){
            if(!ans[len]){
            ans[len]=it->first;
            cnt++;
            }
            len--;
        }
        it++;
    }
    FOR(i,1,n+1)
    SOP(ans[i]);*/
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int hi[100010];
int a[100010],b[100010],c[100010];
int main()
{
    int n;
    int k;
    while(scanf("%d",&n)!=-1)
    {
        hi[0]=hi[n+1]=-1;
        memset(c,0,sizeof(c));
        for(int i=1;i<=n;i++)
            scanf("%d",&hi[i]);
        for(int i=1;i<=n;i++)
            a[i]=b[i]=i;
        for(int i=1;i<=n;i++)
        {
            for(;hi[a[i]-1]>=hi[i];)
            a[i]=a[a[i]-1];
        }
        for(int i=n;i;i--)
        {
            for(;hi[b[i]+1]>=hi[i];)
                b[i]=b[b[i]+1];
        }
        for(int i=1;i<=n;i++)
        {
            int cc=b[i]-a[i]+1;
            if(c[cc]<hi[i])
                c[cc]=hi[i];
        }
        k=c[n];
        for(int i=n-1;i;i--)
        {
            if(c[i]>k)
                k=c[i];
            else
                c[i]=k;
        }
        printf("%d",c[1]);
        for(int i=2;i<=n;i++)
            printf(" %d",c[i]);
        printf("\n");
    }
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int hi[100010];
int a[100010],b[100010],c[100010];
int main()
{
    int n;
    int k;
    while(scanf("%d",&n)!=-1)
    {
        hi[0]=hi[n+1]=-1;
        memset(c,0,sizeof(c));
        for(int i=1;i<=n;i++)
            scanf("%d",&hi[i]);
        for(int i=1;i<=n;i++)
            a[i]=b[i]=i;
        for(int i=1;i<=n;i++)
        {
            for(;hi[a[i]-1]>=hi[i];)
            a[i]=a[a[i]-1];
        }
        for(int i=n;i;i--)
        {
            for(;hi[b[i]+1]>=hi[i];)
                b[i]=b[b[i]+1];
        }
        for(int i=1;i<=n;i++)
        {
            int cc=b[i]-a[i]+1;
            if(c[cc]<hi[i])
                c[cc]=hi[i];
        }
        for(int i=n;i;i--)
        {
            if(c[i])
                k=c[i];
            else
                c[i]=k;
        }
        printf("%d",c[1]);
        for(int i=2;i<=n;i++)
            printf(" %d",c[i]);
        printf("\n");
    }
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int hi[200010];
int a[200010],b[200010],c[200010];
int main()
{
    int n;
    int k;
    while(scanf("%d",&n)!=-1)
    {
        hi[0]=hi[n+1]=-1;
        memset(c,0,sizeof(c));
        for(int i=1;i<=n;i++)
            scanf("%d",&hi[i]);
        for(int i=1;i<=n;i++)
            a[i]=b[i]=i;
        for(int i=1;i<=n;i++)
        {
            for(;hi[a[i]-1]>=hi[i];)
            a[i]=a[a[i]-1];
        }
        for(int i=n;i;i--)
        {
            for(;hi[b[i]+1]>=hi[i];)
                b[i]=b[b[i]+1];
        }
        for(int i=1;i<=n;i++)
        {
            int cc=b[i]-a[i]+1;
            if(c[cc]<hi[i])
                c[cc]=hi[i];
        }
        k=c[n];
        for(int i=n-1;i;i--)
        {
            if(c[i]>k)
                k=c[i];
            else
                c[i]=k;
        }
        printf("%d",c[1]);
        for(int i=2;i<=n;i++)
            printf(" %d",c[i]);
        printf("\n");
    }
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<set>
#include<vector>
#include<map>
#include<string>
#include<cmath>
#define pq priority_queue
#define Pi acos(-1.0)
using namespace std;
struct Node
{
    int num,val;
}nums[200005];
int stc[200005],top=0,ans[200005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&nums[i].num);
    }
    for(int i=1;i<=n;i++)
    {
        while(nums[stc[top]].num>nums[i].num)
        {
            nums[stc[top]].val+=i-stc[top];
            nums[i].val=i-stc[top];
            top--;
        }
        nums[i].val=i-stc[top]-1;
        stc[++top]=i;
    }
    while(top)
    {
        nums[stc[top]].val+=n+1-stc[top];
        top--;
    }
    for(int i=1;i<=n;i++)
    {
        if(nums[i].num>ans[nums[i].val])
            ans[nums[i].val]=nums[i].num;
    }
    for(int i=n;i;i--)
    {
        if(ans[i]==0)
            ans[i]=ans[i+1];
    }
    for(int i=1;i<=n;i++)
    {
        if(i>1)
            printf(" ");
        printf("%d",ans[i]);
    }
    printf("\n");
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<set>
#include<vector>
#include<map>
#include<string>
#include<cmath>
#define pq priority_queue
#define Pi acos(-1.0)
using namespace std;
struct Node
{
    int num,val;
}nums[200005];
int stc[200005],top=0,ans[200005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&nums[i].num);
    }
    for(int i=1;i<=n;i++)
    {
        while(nums[stc[top]].num>=nums[i].num)
        {
            nums[stc[top]].val+=i-stc[top];
            if(nums[stc[top]].num==nums[i].num)
            nums[stc[top]].val++;
            top--;
        }
        nums[i].val=i-stc[top]-1;
        stc[++top]=i;
    }
    while(top)
    {
        nums[stc[top]].val+=n+1-stc[top];
        top--;
    }
    for(int i=1;i<=n;i++)
    {
        if(nums[i].num>ans[nums[i].val])
            ans[nums[i].val]=nums[i].num;
    }
    for(int i=n;i;i--)
    {
        if(ans[i]==0)
            ans[i]=ans[i+1];
    }
    for(int i=1;i<=n;i++)
    {
        if(i>1)
            printf(" ");
        printf("%d",ans[i]);
    }
    printf("\n");
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<set>
#include<vector>
#include<map>
#include<string>
#include<cmath>
#define pq priority_queue
#define Pi acos(-1.0)
using namespace std;
struct Node
{
    int num,val;
}nums[200005];
int stc[200005],top=0,ans[200005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&nums[i].num);
    }
    for(int i=1;i<=n;i++)
    {
        while(nums[stc[top]].num>nums[i].num)
        {
            nums[stc[top]].val+=i-stc[top];
            nums[i].val=i-stc[top];
            top--;
        }
        int temp=top;
        while(nums[stc[temp]].num==nums[i].num)
        {
            nums[i].val=i-stc[temp];
            temp--;
        }
        stc[++top]=i;
    }
    while(top)
    {
        nums[stc[top]].val+=n+1-stc[top];
        top--;
    }
    for(int i=1;i<=n;i++)
    {
        if(nums[i].num>ans[nums[i].val])
            ans[nums[i].val]=nums[i].num;
    }
    for(int i=n;i;i--)
    {
        if(!ans[i])
            ans[i]=ans[i+1];
    }
    for(int i=1;i<=n;i++)
    {
        if(i>1)
            printf(" ");
        printf("%d",ans[i]);
    }
    printf("\n");
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<set>
#include<vector>
#include<map>
#include<string>
#include<cmath>
#define pq priority_queue
#define Pi acos(-1.0)
using namespace std;
struct Node
{
    int num,val;
}nums[200005];
int stc[200005],top=0,ans[200005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&nums[i].num);
    }
    for(int i=1;i<=n;i++)
    {
        while(nums[stc[top]].num>=nums[i].num)
        {
            nums[stc[top]].val+=i-stc[top];
            nums[i].val=i-stc[top];
            top--;
        }
        nums[i].val=i-stc[top]-1;
        stc[++top]=i;
    }
    while(top)
    {
        nums[stc[top]].val+=n+1-stc[top];
        top--;
    }
    for(int i=1;i<=n;i++)
    {
        if(nums[i].num>ans[nums[i].val])
            ans[nums[i].val]=nums[i].num;
    }
    for(int i=n;i;i--)
    {
        if(ans[i]==0)
            ans[i]=ans[i+1];
    }
    for(int i=1;i<=n;i++)
    {
        if(i>1)
            printf(" ");
        printf("%d",ans[i]);
    }
    printf("\n");
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<set>
#include<vector>
#include<map>
#include<string>
#include<cmath>
#define pq priority_queue
#define Pi acos(-1.0)
using namespace std;
struct Node
{
    int num,val;
}nums[200005];
int stc[200005],top=0,ans[200005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&nums[i].num);
    }
    for(int i=1;i<=n;i++)
    {
        while(nums[stc[top]].num>=nums[i].num)
        {
            nums[stc[top]].val+=i-stc[top];
            if(nums[stc[top]].num==nums[i].num)
            nums[stc[top]].val++;
            top--;
        }
        nums[i].val=i-stc[top]-1;
        stc[++top]=i;
    }
    while(top)
    {
        nums[stc[top]].val+=n+1-stc[top];
        top--;
    }
    for(int i=1;i<=n;i++)
    {
        if(nums[i].num>ans[nums[i].val])
            ans[nums[i].val]=nums[i].num;
    }
    for(int i=n;i;i--)
    {
        if(ans[i]<ans[i+1])
            ans[i]=ans[i+1];
    }
    for(int i=1;i<=n;i++)
    {
        if(i>1)
            printf(" ");
        printf("%d",ans[i]);
    }
    printf("\n");
    return 0;
}


#include <bits/stdc++.h>

#define FILE    0
#define INPUT   "input"
#define OUTPUT  "output"

#define MP      make_pair
#define MT      make_tuple
#define PB      push_back
#define FI      first
#define SE      second

#define MAX     int( 1e6+100 )
#define INF     INT_MAX
#define EPS     int(1e-7)
#define MOD     int(1e7+7)
#define PI      acos(-1)

typedef long long ll;

using namespace std;

int n, parent[ MAX ], sz[ MAX ], ans;
pair< int, int > a[ MAX ], cur;
bool used[ MAX ];

void initialize( ) {
    for( int i = 0; i < n; i++ ) {
        parent[ i ] = i;
        sz[ i ] = 1;
    }
}

int Find( int x ) {
    if( parent[ x ] == x ) return x;
    return parent[ x ] = Find( parent[ x ] );
}

void Merge( int x, int y ) {
    int xRoot = Find( x );
    int yRoot = Find( y );
    if( sz[ xRoot ] > sz[ yRoot ] ) {
        parent[ yRoot ] = xRoot;
        sz[ xRoot ] += sz[ yRoot ];
    }
    else {
        parent[ xRoot ] = yRoot;
        sz[ yRoot ] += sz[ xRoot ];
    }
}

int main( ) {

    cin.tie( 0 ); ios_base::sync_with_stdio( 0 );

    if( FILE & 1 ) freopen( INPUT , "r", stdin  );
    if( FILE & 2 ) freopen( OUTPUT, "w", stdout );

    cin >> n;
    for( int i = 0; i < n; i++ ) cin >> a[ i ].FI, a[ i ].SE = i;
    sort( a, a+n ); reverse( a, a+n );

    initialize( );
    for( int i = 0; i < n; i++ ) {
        cur =  a[ i ];
        used[ cur.SE ] = true;
        if( cur.SE > 0 && used[ cur.SE-1 ] ) Merge( cur.SE-1, cur.SE );
        if( cur.SE < n-1 && used[ cur.SE+1 ] ) Merge( cur.SE, cur.SE+1 );
        if( sz[ Find( cur.SE ) ] > ans ) {
            ans++;
            cout << cur.FI;
            if( ans < n-1 ) cout << " ";
        }
    }
    if( ans < n-1 ) cout << cur.FI;
    cout << "\n";

    return 0;
}


#include <bits/stdc++.h>

#define FILE    0
#define INPUT   "input"
#define OUTPUT  "output"

#define MP      make_pair
#define MT      make_tuple
#define PB      push_back
#define FI      first
#define SE      second

#define MAX     int( 1e6+100 )
#define INF     INT_MAX
#define EPS     int(1e-7)
#define MOD     int(1e7+7)
#define PI      acos(-1)

typedef long long ll;

using namespace std;

int n, parent[ MAX ], sz[ MAX ], ans;
pair< int, int > a[ MAX ], cur;
bool used[ MAX ];

void initialize( ) {
    for( int i = 0; i < n; i++ ) {
        parent[ i ] = i;
        sz[ i ] = 1;
    }
}

int Find( int x ) {
    if( parent[ x ] == x ) return x;
    return parent[ x ] = Find( parent[ x ] );
}

void Merge( int x, int y ) {
    int xRoot = Find( x );
    int yRoot = Find( y );
    if( sz[ xRoot ] > sz[ yRoot ] ) {
        parent[ yRoot ] = xRoot;
        sz[ xRoot ] += sz[ yRoot ];
    }
    else {
        parent[ xRoot ] = yRoot;
        sz[ yRoot ] += sz[ xRoot ];
    }
}

int main( ) {

    cin.tie( 0 ); ios_base::sync_with_stdio( 0 );

    if( FILE & 1 ) freopen( INPUT , "r", stdin  );
    if( FILE & 2 ) freopen( OUTPUT, "w", stdout );

    cin >> n;
    for( int i = 0; i < n; i++ ) cin >> a[ i ].FI, a[ i ].SE = i;
    sort( a, a+n ); reverse( a, a+n );

    initialize( );
    for( int i = 0; i < n; i++ ) {
        cur =  a[ i ];
        used[ cur.SE ] = true;
        if( cur.SE > 0 && used[ cur.SE-1 ] ) Merge( cur.SE-1, cur.SE );
        if( cur.SE < n-1 && used[ cur.SE+1 ] ) Merge( cur.SE, cur.SE+1 );
        while( sz[ Find( cur.SE ) ] > ans ) {
            ans++;
            cout << cur.FI << " ";
        }
    }
    cout << "\n";

    return 0;
}


#include <bits/stdc++.h>

#define FILE    0
#define INPUT   "input"
#define OUTPUT  "output"

#define MP      make_pair
#define MT      make_tuple
#define PB      push_back
#define FI      first
#define SE      second

#define MAX     int( 1e6+100 )
#define INF     INT_MAX
#define EPS     int(1e-7)
#define MOD     int(1e7+7)
#define PI      acos(-1)

typedef long long ll;

using namespace std;

int n, parent[ MAX ], sz[ MAX ], ans;
pair< int, int > a[ MAX ], cur;
bool used[ MAX ];

void initialize( ) {
    for( int i = 0; i < n; i++ ) {
        parent[ i ] = i;
        sz[ i ] = 1;
    }
}

int Find( int x ) {
    if( parent[ x ] == x ) return x;
    return parent[ x ] = Find( parent[ x ] );
}

void Merge( int x, int y ) {
    int xRoot = Find( x );
    int yRoot = Find( y );
    if( sz[ xRoot ] > sz[ yRoot ] ) {
        parent[ yRoot ] = xRoot;
        sz[ xRoot ] += sz[ yRoot ];
    }
    else {
        parent[ xRoot ] = yRoot;
        sz[ yRoot ] += sz[ xRoot ];
    }
}

int main( ) {

    cin.tie( 0 ); ios_base::sync_with_stdio( 0 );

    if( FILE & 1 ) freopen( INPUT , "r", stdin  );
    if( FILE & 2 ) freopen( OUTPUT, "w", stdout );

    cin >> n;
    for( int i = 0; i < n; i++ ) cin >> a[ i ].FI, a[ i ].SE = i;
    sort( a, a+n ); reverse( a, a+n );

    initialize( );
    for( int i = 0; i < n; i++ ) {
        cur =  a[ i ];
        used[ cur.SE ] = true;
        if( cur.SE > 0 && used[ cur.SE-1 ] ) Merge( cur.SE-1, cur.SE );
        if( cur.SE < n-1 && used[ cur.SE+1 ] ) Merge( cur.SE, cur.SE+1 );
        while( sz[ Find( cur.SE ) ] > ans ) {
            ans++;
            cout << cur.FI;
            if( ans < n ) cout << " ";
        }
    }
    cout << "\n";

    return 0;
}


#include <bits/stdc++.h>

#define FILE    0
#define INPUT   "input"
#define OUTPUT  "output"

#define MP      make_pair
#define MT      make_tuple
#define PB      push_back
#define FI      first
#define SE      second

#define MAX     int( 1e6+100 )
#define INF     INT_MAX
#define EPS     int(1e-7)
#define MOD     int(1e7+7)
#define PI      acos(-1)

typedef long long ll;

using namespace std;

int n, parent[ MAX ], sz[ MAX ], ans;
pair< int, int > a[ MAX ], cur;
bool used[ MAX ];

void initialize( ) {
    for( int i = 0; i < n; i++ ) {
        parent[ i ] = i;
        sz[ i ] = 1;
    }
}

int Find( int x ) {
    if( parent[ x ] == x ) return x;
    return parent[ x ] = Find( parent[ x ] );
}

void Merge( int x, int y ) {
    int xRoot = Find( x );
    int yRoot = Find( y );
    if( sz[ xRoot ] > sz[ yRoot ] ) {
        parent[ yRoot ] = xRoot;
        sz[ xRoot ] += sz[ yRoot ];
    }
    else {
        parent[ xRoot ] = yRoot;
        sz[ yRoot ] += sz[ xRoot ];
    }
}

int main( ) {

    cin.tie( 0 ); ios_base::sync_with_stdio( 0 );

    if( FILE & 1 ) freopen( INPUT , "r", stdin  );
    if( FILE & 2 ) freopen( OUTPUT, "w", stdout );

    cin >> n;
    for( int i = 0; i < n; i++ ) cin >> a[ i ].FI, a[ i ].SE = i;
    sort( a, a+n ); reverse( a, a+n );

    initialize( );
    for( int i = 0; i < n; i++ ) {
        cur =  a[ i ];
        used[ cur.SE ] = true;
        if( cur.SE > 0 && used[ cur.SE-1 ] ) Merge( cur.SE-1, cur.SE );
        if( cur.SE < n-1 && used[ cur.SE+1 ] ) Merge( cur.SE, cur.SE+1 );
        if( sz[ Find( cur.SE ) ] > ans ) {
            ans++;
            cout << cur.FI << " ";
        }
    }
    cout << cur.FI << "\n";

    return 0;
}


#include <bits/stdc++.h>

#define FILE    0
#define INPUT   "input"
#define OUTPUT  "output"

#define MP      make_pair
#define MT      make_tuple
#define PB      push_back
#define FI      first
#define SE      second

#define MAX     int( 1e6+100 )
#define INF     INT_MAX
#define EPS     int(1e-7)
#define MOD     int(1e7+7)
#define PI      acos(-1)

typedef long long ll;

using namespace std;

int n, parent[ MAX ], sz[ MAX ], ans;
pair< int, int > a[ MAX ], cur;
bool used[ MAX ];

void initialize( ) {
    for( int i = 0; i < n; i++ ) {
        parent[ i ] = i;
        sz[ i ] = 1;
    }
}

int Find( int x ) {
    if( parent[ x ] == x ) return x;
    return parent[ x ] = Find( parent[ x ] );
}

void Merge( int x, int y ) {
    int xRoot = Find( x );
    int yRoot = Find( y );
    if( sz[ xRoot ] > sz[ yRoot ] ) {
        parent[ yRoot ] = xRoot;
        sz[ xRoot ] += sz[ yRoot ];
    }
    else {
        parent[ xRoot ] = yRoot;
        sz[ yRoot ] += sz[ xRoot ];
    }
}

int main( ) {

    cin.tie( 0 ); ios_base::sync_with_stdio( 0 );

    if( FILE & 1 ) freopen( INPUT , "r", stdin  );
    if( FILE & 2 ) freopen( OUTPUT, "w", stdout );

    cin >> n;
    for( int i = 0; i < n; i++ ) cin >> a[ i ].FI, a[ i ].SE = i;
    sort( a, a+n ); reverse( a, a+n );

    initialize( );
    for( int i = 0; i < n; i++ ) {
        cur =  a[ i ];
        used[ cur.SE ] = true;
        if( cur.SE > 0 && used[ cur.SE-1 ] ) Merge( cur.SE-1, cur.SE );
        if( cur.SE < n-1 && used[ cur.SE+1 ] ) Merge( cur.SE, cur.SE+1 );
        if( sz[ Find( cur.SE ) ] > ans ) {
            ans++;
            cout << cur.FI;
            if( ans < n-1 ) cout << " ";
        }
    }
    if( ans < n ) cout << cur.FI;
    cout << "\n";

    return 0;
}


#include <bits/stdc++.h>

#define FILE    0
#define INPUT   "input"
#define OUTPUT  "output"

#define MP      make_pair
#define MT      make_tuple
#define PB      push_back
#define FI      first
#define SE      second

#define MAX     int( 1e6+100 )
#define INF     INT_MAX
#define EPS     int(1e-7)
#define MOD     int(1e7+7)
#define PI      acos(-1)

typedef long long ll;

using namespace std;

int n, parent[ MAX ], sz[ MAX ], ans;
pair< int, int > a[ MAX ], cur;
bool used[ MAX ];

void initialize( ) {
    for( int i = 0; i < n; i++ ) {
        parent[ i ] = i;
        sz[ i ] = 1;
    }
}

int Find( int x ) {
    if( parent[ x ] == x ) return x;
    return parent[ x ] = Find( parent[ x ] );
}

void Merge( int x, int y ) {
    int xRoot = Find( x );
    int yRoot = Find( y );
    if( sz[ xRoot ] > sz[ yRoot ] ) {
        parent[ yRoot ] = xRoot;
        sz[ xRoot ] += sz[ yRoot ];
    }
    else {
        parent[ xRoot ] = yRoot;
        sz[ yRoot ] += sz[ xRoot ];
    }
}

int main( ) {

    cin.tie( 0 ); ios_base::sync_with_stdio( 0 );

    if( FILE & 1 ) freopen( INPUT , "r", stdin  );
    if( FILE & 2 ) freopen( OUTPUT, "w", stdout );

    cin >> n;
    for( int i = 0; i < n; i++ ) cin >> a[ i ].FI, a[ i ].SE = i;
    sort( a, a+n ); reverse( a, a+n );

    initialize( );
    for( int i = 0; i < n; i++ ) {
        cur =  a[ i ];
        used[ cur.SE ] = true;
        if( cur.SE > 0 && used[ cur.SE-1 ] ) Merge( cur.SE-1, cur.SE );
        if( cur.SE < n-1 && used[ cur.SE+1 ] ) Merge( cur.SE, cur.SE+1 );
        if( sz[ Find( cur.SE ) ] > ans ) {
            ans++;
            cout << cur.FI;
            if( ans < n ) cout << " ";
        }
    }
    if( ans < n ) cout << cur.FI;
    cout << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5, MOD = 1e9 + 7;

int n, result[N];
pair<int, int> p[N];

int parent[N], sz[N], rnk[N];

void init() {
	memset(rnk, 0, sizeof rnk);
	for (int i = 0; i < N; ++i) {
		parent[i] = i;
		sz[i] = 1;
	}
}

int root(int node) {
	while (node != parent[node]) {
		parent[node] = parent[parent[node]];
		node = parent[node];
	}
	return node;
}

bool join(int u, int v) {
	u = root(u);
	v = root(v);
	if (u == v)
		return false;
	if (rnk[u] < rnk[v])
		swap(u, v);
	rnk[u] += rnk[u] == rnk[v];
	sz[u] += sz[v];
	parent[v] = u;
	return true;
}
bool vis[N];
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
#endif
	init();
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &p[i].first);
		p[i].second = i;
	}
	sort(p + 1, p + n + 1);
	reverse(p + 1, p + n + 1);
	for (int i = 1; i <= n; ++i) {
		++vis[p[i].second];
		if (vis[p[i].second + 1]) {
			join(p[i].second, p[i].second + 1);
		}
		if (vis[p[i].second - 1]) {
			join(p[i].second, p[i].second - 1);
		}
		result[sz[p[i].second]] = max(result[sz[p[i].second]], p[i].first);
	}
	for (int i = n - 1; i >= 1; --i) {
		result[i] = max(result[i], result[i + 1]);
	}
	for (int i = 1; i <= n; ++i) {
		printf("%d%c", result[i], " \n"[i == n]);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5, MOD = 1e9 + 7;

int n, result[N];
pair<int, int> p[N];
set<pair<int, int>> segments;
bool left(int index) {
	auto it = segments.lower_bound({index, 0});
	return it != segments.end() && it->first == index + 1;
}
bool right(int index) {
	auto it = segments.lower_bound({index, 0});
	return it != segments.begin() && (--it)->second == index - 1;
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
#endif
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &p[i].first);
		p[i].second = i;
	}
	sort(p, p + n);
	reverse(p, p + n);
	for (int i = 0; i < n; ++i) {
		int length;
		if (!left(p[i].second) && !right(p[i].second)) {
			segments.insert({p[i].second, p[i].second});
			length = 1;
		} else if (left(p[i].second) && right(p[i].second)) {
			auto it = segments.lower_bound({p[i].second, 0});
			int right = it->second;
			segments.erase(it);
			it = segments.lower_bound({p[i].second, 0});
			int left = it->first;
			--it;
			segments.erase(it);
			segments.insert({left, right});
			length = right - left + 1;
		} else if (left(p[i].second)) {
			auto it = segments.lower_bound({p[i].second, 0});
			auto tmp = *it;
			segments.erase(it);
			--tmp.first;
			segments.insert(tmp);
			length = tmp.second - tmp.first + 1;
		} else {
			auto it = segments.lower_bound({p[i].second, 0});
			--it;
			auto tmp = *it;
			segments.erase(it);
			++tmp.second;
			segments.insert(tmp);
			length = tmp.second - tmp.first + 1;
		}
		result[length] = max(result[length], p[i].first);
	}
	for (int i = n - 1; i >= 1; --i) {
		result[i] = max(result[i], result[i + 1]);
	}
	for (int i = 1; i <= n; ++i) {
		printf("%d%c", result[i], " \n"[i == n]);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5, MOD = 1e9 + 7;

int n, result[N];
pair<int, int> p[N];

int parent[N], sz[N], rnk[N];

void init() {
	memset(rnk, 0, sizeof rnk);
	for (int i = 0; i < N; ++i) {
		parent[i] = i;
		sz[i] = 1;
	}
}

int root(int node) {
	while (node != parent[node]) {
		parent[node] = parent[parent[node]];
		node = parent[node];
	}
	return node;
}

bool join(int u, int v) {
	u = root(u);
	v = root(v);
	if (u == v)
		return false;
	if (rnk[u] < rnk[v])
		swap(u, v);
	rnk[u] += rnk[u] == rnk[v];
	sz[u] += sz[v];
	parent[v] = u;
	return true;
}
bool vis[N];
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
#endif
	init();
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &p[i].first);
		p[i].second = i;
	}
	sort(p + 1, p + n + 1);
	reverse(p + 1, p + n + 1);
	for (int i = 1; i <= n; ++i) {
		++vis[p[i].second];
		if (vis[p[i].second + 1]) {
			join(p[i].second, p[i].second + 1);
		}
		if (vis[p[i].second - 1]) {
			join(p[i].second, p[i].second - 1);
		}
		result[sz[root(p[i].second)]] = max(result[sz[root(p[i].second)]], p[i].first);
	}
	for (int i = n - 1; i >= 1; --i) {
		result[i] = max(result[i], result[i + 1]);
	}
	for (int i = 1; i <= n; ++i) {
		printf("%d%c", result[i], " \n"[i == n]);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5, MOD = 1e9 + 7;

int n, result[N];
pair<int, int> p[N];
set<pair<int, int>> segments;
bool left(int index) {
	auto it = segments.lower_bound({index, 0});
	return it != segments.end() && it->first == index + 1;
}
bool right(int index) {
	auto it = segments.lower_bound({index, 0});
	return it != segments.begin() && (--it)->second == index - 1;
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
#endif
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &p[i].first);
		p[i].second = i;
	}
	sort(p, p + n);
	reverse(p, p + n);
	for (int i = 0; i < n; ++i) {
		int length;
		if (!left(p[i].second) && !right(p[i].second)) {
			segments.insert({p[i].second, p[i].second});
			length = 1;
		} else if (left(p[i].second) && right(p[i].second)) {
			auto it = segments.lower_bound({p[i].second, 0});
			int right = it->second;
			segments.erase(it);
			it = segments.lower_bound({p[i].second, 0});
			--it;
			int left = it->first;
			segments.erase(it);
			segments.insert({left, right});
			length = right - left + 1;
		} else if (left(p[i].second)) {
			auto it = segments.lower_bound({p[i].second, 0});
			auto tmp = *it;
			segments.erase(it);
			--tmp.first;
			segments.insert(tmp);
			length = tmp.second - tmp.first + 1;
		} else {
			auto it = segments.lower_bound({p[i].second, 0});
			--it;
			auto tmp = *it;
			segments.erase(it);
			++tmp.second;
			segments.insert(tmp);
			length = tmp.second - tmp.first + 1;
		}
		result[length] = max(result[length], p[i].first);
	}
	for (int i = n - 1; i >= 1; --i) {
		result[i] = max(result[i], result[i + 1]);
	}
	for (int i = 1; i <= n; ++i) {
		printf("%d%c", result[i], " \n"[i == n]);
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int a[200005] , mn[200005] , n , ans[200005];

int main()
{
	cin >> n;
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	stack < pair < int , int > > st;
	st.push(make_pair(n-1,a[n-1]));
	for(int i=n-2;i>=0;i--)
	{
		while(!st.empty() && st.top().second >= a[i]) st.pop();
		if(st.empty()) mn[i] = n;
		else mn[i] = st.top().first;
		st.push(make_pair(i,a[i]));
	}
	mn[n-1] = n;

	for(int i=0;i<n;i++)
	{
		int dis = mn[i] - i;
		ans[dis] = max(ans[dis] , a[i]);
	}

	for(int i=n;i>=1;i--)
	{
		ans[i] = max(ans[i] , ans[i+1]);
	}

	for(int i=1;i<=n;i++)
	{
		printf("%d ",ans[i]);
	}
}


#include <bits/stdc++.h>
using namespace std;

int a[200005] , mn[200005] , n , ans[200005];

int main()
{
	cin >> n;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	stack < pair < int , int > > st;
	st.push(make_pair(n,a[n]));
	for(int i=n-1;i>=1;i--)
	{
		while(!st.empty() && st.top().second >= a[i]) st.pop();
		if(st.empty()) mn[i] = n+1;
		else mn[i] = st.top().first;
		st.push(make_pair(i,a[i]));
	}
	mn[n] = n + 1;

	for(int i=1;i<=n;i++)
	{
		int dis = mn[i] - i;
		ans[dis] = max(ans[dis] , a[i]);
	}

	for(int i=n;i>=1;i--)
	{
		ans[i] = max(ans[i] , ans[i+1]);
	}

	for(int i=1;i<=n;i++)
	{
		printf("%d ",ans[i]);
	}
}


#include <bits/stdc++.h>
using namespace std;

int a[200005] , mn[200005] , n , ans[200005] , mnmn = 1e9 + 10;

int main()
{
	cin >> n;
	for(int i=1;i<=n;i++){ scanf("%d",&a[i]); mnmn = min(mnmn , a[i]); }
	stack < pair < int , int > > st;
	st.push(make_pair(n,a[n]));
	for(int i=n-1;i>=1;i--)
	{
		while(!st.empty() && st.top().second >= a[i]) st.pop();
		if(st.empty()) mn[i] = n+1;
		else mn[i] = st.top().first;
		st.push(make_pair(i,a[i]));
	}
	mn[n] = n + 1;
	ans[n] = mnmn;
	for(int i=1;i<=n;i++)
	{
		int dis = mn[i] - i;
		ans[dis] = max(ans[dis] , a[i]);
	}

	for(int i=n;i>=1;i--)
	{
		ans[i] = max(ans[i] , ans[i+1]);
	}

	for(int i=1;i<=n;i++)
	{
		printf("%d ",ans[i]);
	}
}


#include <bits/stdc++.h>
using namespace std;

int l[200005] , a[200005] , mn[200005] , n , ans[200005] , mnmn = 1e9 + 10;

int main()
{
	cin >> n;
	for(int i=1;i<=n;i++){ scanf("%d",&a[i]); mnmn = min(mnmn , a[i]); }
	stack < pair < int , int > > st;
	st.push(make_pair(n,a[n]));
	for(int i=n-1;i>=1;i--)
	{
		while(!st.empty() && st.top().second >= a[i]) st.pop();
		if(st.empty()) mn[i] = n+1;
		else mn[i] = st.top().first;
		st.push(make_pair(i,a[i]));
	}
	mn[n] = n + 1;
	ans[n] = mnmn;
	while(!st.empty()) st.pop();
	st.push(make_pair(1,a[1]));

	for(int i=2;i<=n;i++)
	{
		while(!st.empty() && st.top().second >= a[i]) st.pop();
		if(st.empty()) l[i] = 0;
		else l[i] = st.top().first;
		st.push(make_pair(i,a[i]));
	}

	for(int i=1;i<=n;i++)
	{
		int dis = mn[i] - l[i] - 1;
		ans[dis] = max(ans[dis] , a[i]);
	}

	for(int i=n;i>=1;i--)
	{
		ans[i] = max(ans[i] , ans[i+1]);
	}

	for(int i=1;i<=n;i++)
	{
		printf("%d ",ans[i]);
	}
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <array>
#include <set>
#include <stack>

using namespace std;
using VI = vector<int>;
using STK = stack<int>;

const int SZ = (int)2e5 + 5;
const bool dbg = true;
class D {
    public:
        VI inp, left, right;
        array<int, SZ> maxVBylen{};

        void start() {
            int t; cin >> t;
            for (int i = 0; i < t; i++) {
                int u; cin >> u;
                inp.insert(end(inp), u);
            }
            maxVBylen.fill(0);
            findLeftEndpoints();
            findRightEndpoints();
            updateMaxValueByLen();
        }

        void updateMaxValueByLen() {
            for (int i = 0; i < inp.size(); i++) {
                int len = right[i] - left[i] -1;
                maxVBylen[len] = max(maxVBylen[len], inp[i]);
            }
            int prev = 0;
            for (int i = inp.size()-1; i >= 0; i--) {
                maxVBylen[i] = max(prev, maxVBylen[i]);
                prev = maxVBylen[i];
            }
            for (int i = 0; i < inp.size(); i++) cout << maxVBylen[i] << " ";

        }

        /*
        void printEndpoints(VI& ep) {
            for (auto& i: ep) {
                cout << inp[i] << " ";
            }
            cout << "\n";
        }
        */
        void findLeftEndpoints() {
            STK stk;
            for (int i = 0; i < inp.size(); i++) {
                findMaxLeast(i, stk, left, true);
            }
        }

        void findRightEndpoints() {
            STK stk;
            for (int i = inp.size() - 1; i >= 0; i--) {
                findMaxLeast(i, stk, right, false);
            }
        }

        void findMaxLeast(int idx, STK& stk, VI& v, bool isLeft) {
            int t = isLeft ? -1: inp.size();
            if (!stk.empty()) {
                t = stk.top();
                while (inp[t] >= inp[idx]) {
                    stk.pop();
                    if (!stk.empty()) {
                        t = stk.top();
                    } else {
                        t = isLeft ? -1: inp.size();
                        break;
                    }
                }
            }
            v.insert(end(v), t);
            stk.push(idx);
        }

};

D d;
int main(int argc, char **argv) {
    d.start();
    return 0;
}


#include<bits/stdc++.h>

#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define FORU(I,A,B) for(unsigned int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define REPU(I,N)   FORU(I,0,N)
#define ALL(A)     (A).begin(), (A).end()

using namespace std;

typedef pair <int, int> PI;
typedef vector <int> VI;
typedef vector <string> VS;

typedef long long LL;
const int SZ = (int) (2e5 + 10);
const int WD = 19;
const int INF = (int) (1e10);
const bool dbg = !true;
class D {
    public:
        int table[SZ][WD];
        VI heights;

        void updateQueryTable() {
            for (int i = 0; (1 << i) < heights.size(); i++) {
                int len = (1 << i);
                for (int j = 0; j < heights.size(); j++) {
                    if (i == 0) {
                        table[j][0] = heights[j];
                    } else {
                        if (j + len > heights.size()) continue;
                        int range = 1 << (i-1);
                        table[j][i] = min(table[j][i-1], table[j + range][i-1]);
                    }
                }
            }
        }

        int logBase2(int num) {
            int res = 0;
            while (num > 1) {
                num = num >> 1;
                res++;
            }
            return res;
        }
        bool isPowerOf2(int v) {
            for (int i = 0; (1 << i) <= v; i++) {
                if ((1 << i) == v) return true;
            }
            return false;
        }
        int queryTable(int pos, int len) {
            if (len == 1) return table[pos][0];
            int logLen = logBase2(len);
            //logLen /= 2;
            if (isPowerOf2(len)) return table[pos][logLen];
            return min(table[pos][logLen], table[pos + len - (1 << logLen)][logLen]);
        }
        void printQueryTable() {
            REP(i, heights.size()) {
                for (int j = 0; j < WD; j++) {
                    if (table[i][j] != INF) cout << table[i][j] << " ";
                    else {
                        cout << "\n";
                        break;
                    }
                }
            }
        }

        void printResult() {
            for( int i = 1; i <= heights.size(); i++) {
                int res = 0;
                for( int j = 0; j < heights.size(); j++) {
                    if (i + j > heights.size()) break;
                    res = max(res, queryTable(j, i));
                }
                cout << res << " ";
            }
        }
        void start() {
            int t;
            cin >> t;
            REP(i, SZ) REP(j, WD) table[i][j] = INF;
            REP(i, t) {
                int u; cin >> u;
                heights.push_back(u);
            }
            updateQueryTable();
            if (dbg)  printQueryTable();
            printResult();
            //cout << "\n" << queryTable(2, 4) << "\n";
        }
};

D t;

int main(int argc, char **argv) {
    t.start();
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <array>
#include <set>
#include <stack>

using namespace std;
using VI = vector<int>;
using STK = stack<int>;

const int SZ = (int)2e5 + 5;
const bool dbg = !true;
class D {
    public:
        VI inp, left, right;
        array<int, SZ> maxVBylen{};

        void start() {
            int t; cin >> t;
            for (int i = 0; i < t; i++) {
                int u; cin >> u;
                inp.insert(end(inp), u);
            }
            maxVBylen.fill(0);
            findLeftEndpoints();
            findRightEndpoints();
            updateMaxValueByLen();
        }

        void updateMaxValueByLen() {
            for (int i = 0; i < inp.size(); i++) {
                int len = right[i] - left[i] -1;
                if (dbg) {
                    printf("value=%d, index=%d, leftIdx=%d, rightIdx=%d, len=%d prevMaxV=%d", inp[i], i, left[i], right[i], len, maxVBylen[len]);
                }
                maxVBylen[len] = max(maxVBylen[len], inp[i]);
                if (dbg) {
                    printf(" After update maxV=%d\n", maxVBylen[len]);
                }
            }
            int prev = 0;
            for (int i = inp.size(); i >= 1; i--) {
                maxVBylen[i] = max(prev, maxVBylen[i]);
                prev = maxVBylen[i];
            }
            for (int i = 1; i <= inp.size(); i++) cout << maxVBylen[i] << " ";

        }

        /*
        void printEndpoints(VI& ep) {
            for (auto& i: ep) {
                cout << inp[i] << " ";
            }
            cout << "\n";
        }
        */
        void findLeftEndpoints() {
            STK stk;
            for (int i = 0; i < inp.size(); i++) {
                findMaxLeast(i, stk, left, true);
            }
        }

        void findRightEndpoints() {
            STK stk;
            for (int i = inp.size() - 1; i >= 0; i--) {
                findMaxLeast(i, stk, right, false);
            }
            reverse(begin(right), end(right));
        }

        void findMaxLeast(int idx, STK& stk, VI& v, bool isLeft) {
            int t = isLeft ? -1: inp.size();
            if (!stk.empty()) {
                t = stk.top();
                while (inp[t] >= inp[idx]) {
                    stk.pop();
                    if (!stk.empty()) {
                        t = stk.top();
                    } else {
                        t = isLeft ? -1: inp.size();
                        break;
                    }
                }
            }
            v.insert(end(v), t);
            stk.push(idx);
        }

};

D d;
int main(int argc, char **argv) {
    d.start();
    return 0;
}