#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  vi v(t);
  for (int i = 0; i < t; i++) {
    cin >> v[i];
  }
  int m = t;
  priority_queue<int> qi;
  for (int i = 0; i < t; i++) {
    if (v[i] == m) {
      m--;
      cout << v[i] << " ";
      while (!qi.empty() && (qi.top() == m)) {
        m--;
        cout << qi.top() << " ";
        qi.pop();
      }
    } else
      qi.push(v[i]);
    cout << "\n";
  }
  cerr << "\ntime taken : " << (float)clock() / CLOCKS_PER_SEC << " secs"
       << endl;
  return 0;
}
