#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, a[100000];
  priority_queue<int> lst;
  priority_queue<int> we;
  cin >> n;
  for (i = 0; i < n; i++) {
    int l;
    cin >> l;
    a[i] = l;
    we.push(l);
  }
  for (i = 0; i < n; i++) {
    if (a[i] != we.top()) {
      lst.push(a[i]);
      if (i != n - 1) cout << "\n";
    } else {
      lst.push(a[i]);
      while (!lst.empty()) {
        if (lst.top() == we.top()) {
          cout << lst.top() << " ";
          lst.pop();
          we.pop();
        } else
          break;
      }
      if (i != n - 1) cout << "\n";
    }
  }
  return 0;
}
