#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int> > a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a.begin(), a.end());
  int cur = 0;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = cur; j < a[i].second; j++) cout << '\n';
    cur = max(a[i].second, cur);
    if (a[i].second <= cur) cout << a[i].first << " ";
  }
}
