#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int a;
  cin >> a;
  int b = a;
  set<int, greater<int>> k;
  int i;
  for (i = 0; i < a; i++) {
    int c;
    cin >> c;
    if (c == b) {
      cout << c << " ";
      b--;
      long long f = 0;
      if (k.find(b) != k.end()) {
        for (auto it = k.find(b); it != k.end(); ++it) {
          if (*it == b) {
            cout << *it << " ";
            b--;
            f++;
          } else
            break;
        }
      }
      cout << "\n";
    } else {
      cout << "\n";
      k.insert(c);
    }
  }
}
