#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int j = n;
  int visited[100010] = {0};
  for (int i = 0; i < n; i++) {
    if (a[i] == j) {
      visited[j] = 1;
      while (1) {
        if (visited[j]) {
          cout << j << " ";
          j--;
        } else
          break;
      }
      cout << endl;
    } else {
      visited[a[i]] = 1;
      cout << endl;
    }
  }
  if (j > 0) {
    for (int k = j; k > 0; k--) cout << k << " ";
  }
  return 0;
}
