#include <bits/stdc++.h>
using namespace std;
int main() {
  set<int, greater<int>> s;
  vector<int> v;
  int n, num;
  cin >> n;
  int max = n;
  while (n--) {
    cin >> num;
    int count = 0, count1 = 0;
    int first = 0, second = 0;
    s.insert(num);
    if (num == max) {
      cout << num << " ";
      max = num - 1;
      for (auto it = s.begin(); it != s.end(); it++, count++) {
        first = second;
        second = *it;
        if (second == first - 1 && count >= 1) {
          cout << second << " ";
          v.push_back(second);
          max = second - 1;
          count1++;
        } else if (count >= 1) {
          break;
        }
      }
      cout << endl;
      auto ir = s.begin();
      s.erase(ir);
      for (int i = 0; i < count1; i++) {
        auto it = s.find(v[i]);
        if (it != s.end()) {
          s.erase(it);
        }
      }
      v.clear();
    } else {
      cout << endl;
    }
  }
  s.clear();
}
