#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  stack<int> q;
  set<int> st;
  int n;
  cin >> n;
  int t = n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a == t) {
      cout << a;
      t--;
      if (!st.empty()) {
        while (1) {
          if (st.find(t) != st.end()) {
            cout << " " << t;
            t--;
          } else {
            break;
          }
        }
      }
      cout << "\n";
    } else {
      cout << "\n";
      st.insert(a);
    }
  }
  return 0;
}
