#include <bits/stdc++.h>
using namespace std;
const int N = 200003;
const int LGN = 18;
int h, n, left_most, right_most;
struct node {
  int top;
  node() : top(1e9 + 10) {}
  node(int _x) : top(_x) {}
  void merge(const node& l, const node& r) { top = min(l.top, r.top); }
  void push(node& l, node& r) {}
  void update(int d) { top = d; }
} tree[1 << (LGN + 1)];
inline bool operator<(const node a, const node& n) { return a.top > n.top; }
const node IDENTITY;
node query(int root, int left_leaf, int right_leaf, const int u, const int v) {
  if (u >= v) return IDENTITY;
  if (u <= left_leaf && right_leaf <= v) return tree[root];
  int mid = (left_leaf + right_leaf) >> 1, lc = root << 1, rc = lc | 1;
  tree[root].push(tree[lc], tree[rc]);
  node ret;
  if (v <= mid)
    ret = query(lc, left_leaf, mid, u, v);
  else if (u >= mid)
    ret = query(rc, mid, right_leaf, u, v);
  else
    ret.merge(query(lc, left_leaf, mid, u, v),
              query(rc, mid, right_leaf, u, v));
  return ret;
}
void pushdown(int idx) {
  if (idx > 1) pushdown(idx >> 1);
  tree[idx].push(tree[idx << 1], tree[(idx << 1) | 1]);
}
void update(int idx, node new_node) {
  idx |= (1 << h);
  pushdown(idx >> 1);
  tree[idx] = new_node;
  idx >>= 1;
  while (idx > 0) {
    tree[idx].merge(tree[idx << 1], tree[(idx << 1) | 1]);
    idx >>= 1;
  }
}
void range_update(int root, int left_leaf, int right_leaf, const int u,
                  const int v, int d) {
  if (u >= v) return;
  if (u <= left_leaf && right_leaf <= v) return tree[root].update(d);
  int mid = (left_leaf + right_leaf) >> 1, lc = root << 1, rc = lc | 1;
  tree[root].push(tree[lc], tree[rc]);
  if (u < mid) range_update(lc, left_leaf, mid, u, v, d);
  if (v > mid) range_update(rc, mid, right_leaf, u, v, d);
  tree[root].merge(tree[lc], tree[rc]);
}
void build(int size) {
  n = size;
  h = ceil(log2(n));
  left_most = 1 << h, right_most = left_most << 1;
  for (int i = 0; i < n; i++) tree[i | (1 << h)] = (node){0};
  for (int i = left_most - 1; i > 0; i--)
    tree[i].merge(tree[i << 1], tree[(i << 1) | 1]);
}
int binary_search(node k) {
  int root = 1;
  node nd;
  while (root < left_most) {
    int lc = root << 1, rc = lc | 1;
    tree[root].push(tree[lc], tree[rc]);
    node m;
    m.merge(nd, tree[lc]);
    if (m < k) {
      nd = m;
      root = rc;
    } else {
      root = lc;
    }
  }
  node ret;
  ret.merge(nd, tree[root]);
  if (ret < k)
    return root - left_most;
  else
    return root - 1 - left_most;
}
vector<int> seqs[N];
int main() {
  int n;
  cin >> n;
  build(n);
  for (int i = 0, a; i < n; ++i) {
    cin >> a;
    int idx = binary_search(a) + 1;
    seqs[idx].emplace_back(a);
    update(idx, a);
  }
  for (int i = 0; i < N; ++i)
    if (seqs[i].size()) {
      for (auto e : seqs[i]) cout << e << " ";
      cout << "\n";
    }
  return 0;
}
