#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x = n;
  int a[n];
  priority_queue<int> pq, pq2;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    pq.push(a[i]);
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == x) {
      cout << a[i];
      pq.pop();
      x--;
      for (int j = 0; j < pq2.size(); j++) {
        if (pq2.top() == x) {
          cout << " " << pq2.top();
          pq2.pop();
          --x;
          j--;
        }
      }
      cout << endl;
    } else {
      cout << endl;
      pq2.push(a[i]);
    }
  }
  return 0;
}
