#include <bits/stdc++.h>
using namespace std;
int n, x, m;
priority_queue<int> s;
int main() {
  scanf("%d", &n);
  m = n;
  for (int i = 0; i < int(n); i++) {
    scanf("%d", &x);
    if (x < m) {
      s.push(x);
      cout << " ";
    } else if (x == m) {
      cout << x << " ";
      m--;
      while (!s.empty() && m == s.top()) {
        cout << s.top() << " ";
        s.pop();
        m--;
      }
    }
    cout << endl;
  }
  return 0;
}
