#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  priority_queue<int> pq;
  int A[n], S[n];
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }
  for (int i = n, j = 0; i >= 1; i--, j++) A[j] = i;
  int index = 0;
  for (int i = 0; i < n; i++) {
    pq.push(S[i]);
    if (A[index] == S[i]) {
      while (!pq.empty() && A[index] == pq.top()) {
        cout << pq.top() << " ";
        pq.pop();
        if (pq.top() != A[index] && !pq.empty()) {
          if (pq.top() == A[index + 1] && index < n) index += 1;
        }
      }
      index++;
      cout << "\n";
    } else {
      cout << "\n";
    }
  }
  if (!pq.empty()) {
    while (!pq.empty() && A[index] == pq.top()) {
      cout << pq.top() << " ";
      pq.pop();
      if (pq.top() != A[index] && index < n) {
        if (pq.top() == A[index + 1]) index += 1;
      }
    }
    index++;
    cout << "\n";
  }
  return 0;
}
