#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a;
  cin >> n;
  map<long long, int> m;
  map<long long, int>::iterator it;
  long long z = n;
  for (long long i = 0; i < n; i++) {
    cin >> a;
    if (a == z) {
      z--;
      cout << a << " ";
      while (!m.empty()) {
        it = m.find(z);
        if (it != m.end()) {
          cout << z << " ";
          z--;
          m.erase(it);
        } else
          break;
      }
    } else {
      m[a]++;
    }
    if ((i + 1) != n) cout << endl;
  }
  map<long long, int>::reverse_iterator it1;
  for (it1 = m.rbegin(); it1 != m.rend(); it1++) cout << it1->first << " ";
  return 0;
}
