#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vii;
typedef unsigned us;
#define INF 1e9
#define nl endl
#define faster ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define drep(i, a, b) for (int i = int(a); i > int(b); i--)
#define DREP(i, a, b) for (int i = int(a); i >= int(b); i--)
const int c3 = 1e3 + 2, c4 = 1e4 + 2, c5 = 1e5 + 2, c6 = 1e6 + 2;
int main() {
faster;
int n, *f;
cin >> n;
f = new int[n + 10];
REP (i, 1, n) {
int p;
cin >> p;
f[p] = i;
}
int head = 0;
REP (i, 1, n) {
if (f[i] < head) cout << "," << i;
else {
head = f[i];
if (i != 1) cout << endl;
cout << i;
}
}
}