#include <bits/stdc++.h>
using namespace std;
const long long p = 239017;
const long long mod = 1e9 + 7;
const long long mod2 = 1e9 + 13;
const long long MAXN = 110;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  long long n;
  cin >> n;
  vector<vector<long long>> v(n);
  vector<long long> shit(n);
  for (long long i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    long long it = upper_bound(shit.begin(), shit.end(), x) - shit.begin();
    shit[it - 1] = x;
    v[n - it].push_back(x);
  }
  for (long long i = 0; i < n; ++i) {
    for (long long j = 0; j < v[i].size(); ++j) cout << v[i][j] << " ";
    cout << '\n';
  }
  return 0;
}
