#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> arr(n);
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    arr[i] = x;
  }
  set<int, greater<int>> s;
  int current = n;
  for (int i = 0; i < n; ++i) {
    s.insert(arr[i]);
    bool not_first = false;
    while (s.find(current) != s.end()) {
      if (not_first) {
        cout << " ";
      }
      cout << *s.begin();
      s.erase(current);
      current--;
      not_first = true;
    }
    cout << "\n";
  }
}
