#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  priority_queue<int> q;
  int bottom = n + 1;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (bottom - x == 1) {
      cout << x << " ";
      bottom = x;
      while (!q.empty()) {
        int may_be = q.top();
        if (bottom - may_be == 1) {
          cout << may_be << " ";
          bottom = may_be;
          q.pop();
        } else
          break;
      }
      cout << '\n';
    } else {
      q.push(x);
      cout << '\n';
    }
  }
  return 0;
}
