#include <bits/stdc++.h>
using namespace std;
int a[100005];
bool used[100005];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int u = n;
  for (int i = 0; i < n; i++) {
    if (a[i] == u) {
      used[a[i]] = true;
      int temp = a[i];
      while (used[temp] == true) {
        cout << temp;
        if (used[temp - 1] == true) {
          cout << ' ';
        }
        temp--;
      }
      u = temp;
      if (u) cout << endl;
    } else {
      used[a[i]] = true;
      cout << endl;
    }
  }
  return 0;
}
