#include <iostream>
#include <deque>
using namespace std;
const int N = 1000010;
int a[N];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
deque<int> q;
for (int i = 1; i <= n; i++) {
while (!q.empty() && a[q.back()] <= a[i]) q.pop_back();
q.push_back(i);
}
while (!q.empty()) {
cout << a[q.front()] << " ";
q.pop_front();
}
return 0;
}
0 回复
0 转发
0 喜欢
3 阅读



