#include #define cout std::cout #define cin std::cin #define endl '\n' using ll = long long; const ll inf = 1000000000000000000LL; #include ll op(ll a, ll b) { return 0 ^ a ^ a ^ b ^ b; } ll e() { return 0; } ll mp(ll f, ll x) { if(f == inf) return x; return f; } ll cmp(ll f, ll g) { if(f == inf) return g; return f; } ll id() { return inf; } int main() { std::ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; std::vector A(n); for(int i = 0; i < n; i++) cin >> A[i]; std::map> C; for(int i = 0; i < n; i++) C[A[i]].push_back(i); atcoder::lazy_segtree seg(A); for(auto it = C.begin(); it != C.end(); it++) { std::vector v = it->second; int fi = v.front(), la = v.back(); seg.apply(fi, la + 1, it->first); } for(int i = 0; i < n; i++) cout << seg.get(i) << " "; cout << endl; }