#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  vector<bool> fallen(n, 0);
  for (int i = 0; i < n; i++) cin >> v[i];
  int j = 0;
  int fall = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] == n - j && !fallen[n - j - 1]) {
      fallen[n - j - 1] = 1;
      cout << n - j;
      j++;
      while (n - j - 1 >= 0 && fallen[n - j - 1]) {
        cout << " " << n - j;
        j++;
      }
      cout << endl;
    } else if (v[i] != n - j) {
      cout << endl;
      fallen[v[i] - 1] = 1;
    }
  }
  return 0;
}
