#include <bits/stdc++.h>
using namespace std;
void printnl(int x) {
  for (int i = 0; i < x; i++) cout << "\n";
}
int main() {
  int n;
  cin >> n;
  int x[n], tmp;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    x[tmp - 1] = i;
  }
  tmp = x[n - 1];
  printnl(x[n - 1]);
  cout << n << " ";
  for (int i = n - 2; i >= 0; i--) {
    if (x[i + 1] > x[i]) {
      cout << i + 1 << " ";
    } else {
      printnl(x[i] - tmp);
      if (tmp < x[i]) tmp = x[i];
      cout << i + 1 << " ";
    }
  }
  return 0;
}
