n = int(input())
arr = input().split(' ')
for i in range(len(arr)):
arr[i] = int(arr[i])
needed = n
store=[-1]*(n+10)
for i in arr:
store[i] = i
if i == needed:
while(store[i]!=-1):
print(i,end=' ')
i -= 1
needed = i
print()
#include <bits/stdc++.h>
# define my_sizeof(type) ((char *)(&type+1)-(char*)(&type))
using namespace std;
void Juicer(){
int n , b , d, flow{} , times{};
cin >> n >> b >> d;
int orange;
while(n--){
cin >> orange;
if(orange > b) continue;
flow += orange;
if(flow > d){
times++;
flow = 0;
}
}
cout << times << endl;
}
void Carrot_Cakes(){
// n -> number of cakes needed
// t -> time needed for one oven to bake k cakes
// k -> number of cakes baked at the same time
// d -> time needed to build the second oven
int n , t , k , d;
cin >> n >> t >> k >> d;
int make = (d / t ) * k;
(make + k < n) ? cout << "YES\n" : cout << "NO\n" ;
}
void Hossam(){
long long t, n;
long long first{0}, last{0};
long long f , l;
cin >> t;
while(t--){
f =0;
l = 0;
cin >> n;
vector<long long> arr(n);
for (int i = 0; i < n; ++i) {
cin >> arr[i];
}
std::sort(arr.begin(), arr.end());
last = arr[n-1];
first = arr[0];
for (int i = 0; i < n; ++i) {
if(first == arr[i]) f++;
if(last == arr[n-i-1]) l++;
}
cout << pow(2,f*l) << endl;
}
}
void Anton_and_letters(){
string n;
getline(cin , n);
string temp{};
bool checker;
for (char i : n) {
if(isalpha(i)){
checker = true;
for (char j : temp) {
if(j == i){
checker = false;
break;
}
}
if(checker){
temp += i;
}
}
}
cout << temp.size() << endl;
}
void way_too_long(){
int s;
string word{};
cin >> s;
while(s--){
cin >> word;
s = word.length();
if(s > 10) {
cout << word[0] << s - 2 << word[s - 1] << endl;
}
else{
cout << word << endl;
}
}
}
void free_ice_cream(){
char sign;
long long n , x , num;
cin >> n >> x;
long long dis{0} , rem{x};
while(n--){
cin >> sign >> num;
if(sign == '+') rem += num;
else{
if(rem >= num) rem -= num;
else dis++;
}
}
cout << rem << " " << dis << endl;
}
void Helpful_Maths(){
string s;
cin >> s;
vector<int> v;
for (int i = 0; i < s.size(); i+=2) {
v.push_back(s[i] - 48);
}
std::sort(v.begin(), v.end());
for (int i = 0; i < v.size(); ++i) {
cout << v[i];
if(v.size() != i + 1) cout << "+";
}
}
void Team_Olympiad() {
int n;
int one{}, two{}, three{};
cin >> n;
int *x = new int[n];
for (int i = 0; i < n; ++i) {
cin >> x[i];
if (x[i] == 1) {
one++;
} else if (x[i] == 2) {
two++;
} else {
three++;
}
}
int counter = min({one,two,three});
cout << counter << endl;
for (int i = 0; i < counter; ++i) {
for (int j = 0; j < n; ++j) {
if (x[j] == 1) {
x[j] = 0;
cout << j + 1 << " ";
break;
}
}
for (int k = 0; k < n; ++k) {
if (x[k] == 2) {
x[k] = 0;
cout << k + 1 << " ";
break;
}
}
for (int l = 0; l < n; ++l) {
if (x[l] == 3) {
x[l] = 0;
cout << l + 1;
break;
}
}
cout << endl;
}
}
int NextIsDouble(int data []){
int counter = 0;
int size = sizeof(data) / sizeof(data[0]);
for (int i = 0; i < size; i++) {
if(data[i] * 2 == data[i+1]){
cout << data[i] << " " << data[i+1] << endl;
counter++;
}
}
return counter;
}
void New_password(){
int n , k;
cin >> n >> k;
int dis = min(k , 26);
k = dis;
char sym{'z'};
for (int i = 0; i < n; ++i) {
cout << sym;
sym--;
if(i == dis - 1){
dis += k;
sym = 'z';
}
}
cout << endl;
}
void Light() {
long long n{1}, walk{1};
while (true) {
cin >> n;
if(n == 0) break;
bool state = false;
bool is_on = false;
for (int i = 0; i < n; ++i) {
if (n % walk == 0) {
if (is_on) {
state = false;
is_on = false;
} else {
state = true;
is_on = true;
}
}
walk++;
}
string answer = state ? "yes" : "no";
cout << answer << endl;
}
}
bool hasSubsequence(const string &text, const string& subseq){
for (int i = 0, j = 0; i < text.size(); i++) {
if (text[i] == subseq[j]) {
j++;
}
if(j == subseq.size()) {
return true;
}
}
return false;
}
void Three_numbers(){
int s , k , counter{0};
cin >> k >> s;
for (int i = 0; i <= k; ++i) {
for (int j = 0; j <=k ; ++j) {
if(s - i - j >= 0 && s - i - j <= k) counter++;
}
}
cout << counter << endl;
}
void Diamond(){
int n; cin >> n;
string diamond{};
for (int i = 0; i < n * 2 - 1; ++i){
if(i == n - 1) {
diamond += '*';
break;
}
else diamond += " ";
}
cout << diamond << endl;
for (int start = n - 1; start > 0 ; start--) {
diamond += "*";
diamond[start - 1] = '*';
cout << diamond << endl;
}
cout << diamond << endl;
for (int start = 0; start <= n + 1; start++) {
diamond[start] = ' ';
diamond.pop_back();
cout << diamond << endl;
}
}
void prime() {
int prime;
cin >> prime;
bool flag = true;
for (int i = 2; i < prime; ++i) {
for (int j = 2; j < i ; ++j) {
if(i % j == 0){
flag = false;
break;
}
flag = true;
}
if(flag && prime != 1){
cout << i << ' ';
}
}
}
void Lineland_Mail(){
int n;
cin >> n;
long long mini , maxi;
auto *Xi = new long long [n];
for (int i = 0; i < n; ++i) {
cin >> Xi[i];
} // -5 -2 2 7
for (int i = 0; i < n; ++i) {
if(i == 0){mini = abs(Xi[i] - Xi[i+1]);}
else if(i != n -1){
mini = abs(min( Xi[i] - Xi[i-1] , Xi[i+1] - Xi[i]));
}
else{
mini = abs(Xi[i-1] - Xi[i]);
}
maxi = abs(max(abs(Xi[i] -Xi[0]) , abs(Xi[i] - Xi[n-1])));
cout << mini <<" " << maxi << endl;
}
}
void Longest_uncommon_subsequence(){
string a , b;
vector<string> v{};
cin >> a >> b;
if(a == b){
cout << "-1" << endl;
return;
} else{
for (int i = 0; i < b.size(); ++i) {
}
}
}
void URL(){
string URL;
cin >> URL;
vector<string> info(5);
size_t pos = URL.find('=');
char c{};
size_t i,j{0};
i = pos + 1;
while(j != 5){
c = URL[i];
if(c != '&' && c!= '\0'){
info[j] += URL[i];
i++;
}
else{
j++;
pos = URL.find('=', pos + 1);
i = pos + 1;
}
}
cout << "username: " << info[0]<<endl;
cout << "pwd: " << info[1]<<endl;
cout << "profile: " << info[2]<<endl;
cout << "role: " << info[3]<<endl;
cout << "key: " << info[4]<<endl;
}
void UNCOMMON(){
string a , b;
cin >> a >> b;
long long final{-1};
if(a.size() > b.size() || a.size() < b.size() ) final = max(b.size(),a.size());
else{
for (int i = 0; i < a.size(); ++i) {
if(a[i] == b[i]) continue;
else{
final = max(b.size(),a.size());
break;
}
}
}
cout << final << endl;
}
void snack_tower(){
int n;
cin >> n;
int frq[n+1]= {0};
int max = n;
for (int i = 0; i < n; ++i) {
int num;
cin >> num;
frq[num] = 1;
while(frq[max]){
cout << max <<" ";
max--;
}
cout << endl;
}
}
int main(){
// Juicer();
// Carrot_Cakes();
// way_too_long();
// free_ice_cream();
// Helpful_Maths();
// Team_Olympiad();
// NextIsDouble();
// New_password();
// Light();
//Three_numbers();
//Diamond();
// prime();
// string has = hasSubsequence("","oh yeah") ? "yes" : "no";
// cout << has << endl;
// Lineland_Mail();
// URL();
// UNCOMMON();
snack_tower();
}
561. Array Partition I | 1374. Generate a String With Characters That Have Odd Counts |
1822. Sign of the Product of an Array | 1464. Maximum Product of Two Elements in an Array |
1323. Maximum 69 Number | 832. Flipping an Image |
1295. Find Numbers with Even Number of Digits | 1704. Determine if String Halves Are Alike |
1732. Find the Highest Altitude | 709. To Lower Case |
1688. Count of Matches in Tournament | 1684. Count the Number of Consistent Strings |
1588. Sum of All Odd Length Subarrays | 1662. Check If Two String Arrays are Equivalent |
1832. Check if the Sentence Is Pangram | 1678. Goal Parser Interpretation |
1389. Create Target Array in the Given Order | 1313. Decompress Run-Length Encoded List |
1281. Subtract the Product and Sum of Digits of an Integer | 1342. Number of Steps to Reduce a Number to Zero |
1528. Shuffle String | 1365. How Many Numbers Are Smaller Than the Current Number |
771. Jewels and Stones | 1512. Number of Good Pairs |
672. Richest Customer Wealth | 1470. Shuffle the Array |
1431. Kids With the Greatest Number of Candies | 1480. Running Sum of 1d Array |
682. Baseball Game | 496. Next Greater Element I |