#include <bits/stdc++.h>
using namespace std;
int a[100009], dict[1000009];
int main() {
  int n, i, j, mark;
  cin >> n;
  mark = n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    dict[a[i]] = 1;
    if (a[i] == mark) {
      for (j = a[i]; j >= 1; j--) {
        if (dict[j])
          cout << j << " ";
        else
          break;
      }
      mark = j;
      cout << endl;
    } else
      cout << endl;
  }
  return 0;
}
