#define _USE_MATH_DEFINES #define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" #define rep(i,n) for(int i = 0;i < n;i++) #define REP(i,n,k) for(int i = n;i < k;i++) #define P(p) cout<<(p)<> ret; return ret; } ll gcd(ll a, ll b){ if (b > a)swap(a, b); if (b == 0) return a; return gcd(b, a%b); } void solve() { int n; cin >> n; int A[10000]; int ans[10000]; set s; rep(i, n){ cin >> A[i]; s.insert(A[i]); } for (auto it = s.begin(); it != s.end(); it++){ int f = -1, e = -1; rep(i, n){ if (A[i] == *it && f == -1){ f = i; } else if (A[i] == *it && f != -1){ e = i; } } if (f != -1 && e != -1){ for (int i = f; i <= e; i++){ ans[i] = *it; } } else{ ans[f] = *it; } } rep(i, n){ cout << ans[i]; if (i != n - 1){ cout << " "; } } cout << endl; } int main() { solve(); return 0; }