#include #include #include #include #include #include #include #include #include #include #include #define mk make_pair #define pb push_back #define printf printf_s #define scanf scanf_s using namespace std; typedef long long int ll; typedef pair pos; const ll MOD = 1000000007, N = 100001, dx[4] = { -1,1,0,0 }, dy[4] = { 0,0,-1,1 }, MIN = -72340172838, MAX = 72340172838; ll mn(ll a, ll b) { if (a == -1)return b; if (b == -1)return a; return min(a, b); } ll gcd(ll v1, ll v2) { if (v1 == 0)return v2; if (v2 == 0)return v1; if (v2 > v1)return gcd(v2%v1, v1); return gcd(v1%v2, v2); } ll pw(ll v1, ll v2) { ll v3 = 1; while (v2 > 0) { if (v2 % 2)v3 = (v3*v1) % MOD; v1 = (v1*v1) % MOD; v2 /= 2; } return v3; } struct ab { ll a, b; bool operator<(const ab& right) const { return right.b*a - right.a*b < 0; } }; ll n, a[N],lst_i[N]; map mp1, mp2; priority_queue q; int main() { cin >> n; for (ll i = 0; i < n; i++) { cin >> a[i]; if (mp1.find(a[i]) == mp1.end()) { mp1[a[i]] = i; mp2[a[i]] = i; } mp1[a[i]] = min(i, mp1[a[i]]); mp2[a[i]] = max(i, mp2[a[i]]); } memset(lst_i, -1, sizeof(lst_i)); for (int i = 0; i < n; i++) { if (mp1[a[i]] == i)lst_i[i] = mp2[a[i]]; } for (int i = 0; i < n; i++) { if (lst_i[i] != -1)q.push(mk(a[i], lst_i[i])); while (q.top().second < i)q.pop(); if (i != 0)cout << ' '; cout << q.top().first; } cout << endl; return 0; }