#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, temp;
  vector<int> v;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    v.push_back(temp);
  }
  int lookfor = n;
  unordered_set<int> u;
  for (int i = 0; i < v.size(); i++) {
    if (v[i] == lookfor) {
      cout << v[i];
      lookfor--;
      while (u.find(lookfor) != u.end()) {
        cout << " " << lookfor;
        lookfor--;
      }
      cout << endl;
    } else {
      u.insert(v[i]);
      cout << endl;
    }
  }
}
