#include <bits/stdc++.h>
using namespace std;
int main() {
  long n;
  cin >> n;
  long num, curr = n;
  vector<bool> s(n, false);
  for (int i = 0; i < n; i++) {
    cin >> num;
    if (num == curr) {
      cout << num << " ";
      curr--;
      while (1) {
        if (s[curr]) {
          cout << curr << " ";
          s[curr] = false;
          curr--;
        } else
          break;
      }
      cout << endl;
    } else {
      cout << endl;
      s[num] = true;
    }
  }
  return 0;
}
