#include <bits/stdc++.h>
using namespace std;
void log_time(string s) {
  if (true) {
    chrono::milliseconds ms = chrono::duration_cast<chrono::milliseconds>(
        chrono::system_clock::now().time_since_epoch());
    cout << s << ":" << ms.count() << endl;
  }
}
long long gcd(long long x, long long y) { return y == 0LL ? x : gcd(y, x % y); }
int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }
bool comparator(const pair<long long, long long> &x,
                const pair<long long, long long> &y) {
  return x.second - x.first < y.second - y.first;
}
int f_abs(int x) { return x < 0 ? -x : x; }
void insert(vector<vector<long long> > &xs, long long x) {
  if (xs.empty()) {
    xs.push_back(vector<long long>());
    xs.back().push_back(x);
    return;
  }
  int from = 0, to = xs.size();
  int mid = (from + to) / 2;
  while (from < to) {
    if (xs[mid].back() > x) {
      from = mid + 1;
    } else {
      to = mid;
    }
    mid = (from + to) / 2;
  }
  if (mid >= xs.size()) {
    xs.push_back(vector<long long>());
    xs.back().push_back(x);
  } else {
    xs[mid].push_back(x);
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<long long> > xs(0);
  for (int i = 0; i < int(n); i++) {
    long long t;
    cin >> t;
    insert(xs, t);
  }
  for (int i = 0; i < int(xs.size()); i++) {
    for (int j = 0; j < int(xs[i].size()); j++) {
      cout << xs[i][j] << ' ';
    }
    cout << endl;
  }
  return 0;
}
