#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[100000]; int ans[100000]; map > m; set s; rep(i, n){ cin >> A[i]; ans[i] = A[i]; m[A[i]].push_back(i); s.insert(A[i]); } for (auto it = s.begin(); it != s.end(); it++){ if (m[*it].size() == 1){ ans[m[*it][0]] = *it; } else if (m[*it].size() == 2){ for (int i = m[*it][0]; i <= m[*it][1]; i++){ ans[i] = *it; } } } rep(i, n){ cout << ans[i]; if (i != n - 1){ cout << " "; } } cout << endl; } int main() { solve(); return 0; }