#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  vector<bool> f(n, false);
  long long now = n - 1;
  for (long long i = 0; i < n; i++) {
    f[a[i]] = true;
    if (f[now]) {
      for (long long j = now; j >= 0; j--) {
        if (f[j] == false) {
          now = j;
          break;
        }
        if (j != now) cout << " ";
        cout << j + 1;
      }
    }
    cout << endl;
  }
}
