#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, d;
  cin >> n;
  unordered_set<int> s;
  int mx = n;
  int c = 0;
  for (int i = 0; i < n; i++) {
    cin >> d;
    if (d == mx) {
      for (int i = 0; i < c; i++) cout << "\n";
      cout << mx;
      c = 0;
      int k = mx - 1;
      while (s.find(k) != s.end()) {
        cout << " " << k;
        s.erase(k);
        k--;
      }
      cout << "\n";
      mx = k;
    } else {
      s.insert(d);
      c++;
    }
  }
  return 0;
}
