#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  int N;
  cin >> N;
  vector<int> myVector(N);
  vector<int>::iterator it;
  unordered_set<int> mySet;
  unordered_set<int>::const_iterator got;
  int myExpecValue = N;
  for (int i = 0; i < N; i++) {
    int temp;
    cin >> temp;
    if (temp == myExpecValue) {
      cout << myExpecValue << " ";
      do {
        myExpecValue--;
        got = mySet.find(myExpecValue);
        if (got != mySet.end()) {
          cout << *got << " ";
        }
      } while (got != mySet.end());
      cout << endl;
    } else {
      cout << endl;
      mySet.insert(temp);
    }
  }
  return 0;
}
