#include <bits/stdc++.h>
using namespace std;
int n = 0, ordr = 0, tmpS = 0;
int main() {
  cin >> n;
  ordr = n;
  std::vector<bool> temp(n, false);
  std::vector<int> inp(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> inp[i];
  }
  for (int i = 0; i < n; i++) {
    if (inp[i] == ordr) {
      cout << ordr << " ";
      ordr--;
      while (temp[ordr] == true) {
        cout << ordr << " ", ordr--;
      }
    } else {
      temp[inp[i]] = true;
    }
    cout << "\n";
  }
  return 0;
}
