#include <bits/stdc++.h>
using namespace std;
bool e[100005];
int n, t;
vector<vector<int> > o;
int main() {
  cin >> n;
  int lr = n;
  int lf = -1;
  for (int i = 0; i < n; i++) {
    vector<int> ss;
    cin >> t;
    e[t] = true;
    if (t > lf) lf = t;
    if (lf == lr) {
      for (int j = lr; j >= 1; j--) {
        if (e[j]) {
          ss.push_back(j);
        } else {
          lr = j;
          lf = -1;
          break;
        }
      }
    }
    o.push_back(ss);
  }
  for (int i = 0; i < o.size(); i++) {
    if (o[i].size() == 0) {
      cout << " ";
    } else {
      for (int j = 0; j < o[i].size(); j++) {
        cout << o[i][j] << " ";
      }
    }
    cout << '\n';
  }
}
