#include <bits/stdc++.h>
using namespace std;
long long a[100008], b[100009];
map<long long, long long> mp;
map<long long, long long> mp1;
int main() {
  cin.sync_with_stdio(false);
  long long i, j, k, l, c, v, bbbb[1000], aa[1009], bb[1000], n, m, r, t;
  long long x1, x2, y1, y2, x3, x4, x5, x6;
  string s, s1, s2, s3, ss[10000];
  while (cin >> n) {
    k = n;
    for (i = 0; i < n; i++) {
      cin >> m;
      if (m == k) {
        a[m] = 1;
        for (j = k;; j--) {
          if (a[j] == 1) {
            cout << j << " ";
            k = j;
          } else {
            cout << endl;
            k = j;
            break;
          }
        }
      } else {
        a[m] = 1;
        cout << endl;
      }
    }
  }
}
