#include <bits/stdc++.h>
void print(int allb[], int i, int* k) {
  int j, x = 0;
  for (j = (*k); j > 0; j--) {
    if (allb[j - 1] == (*k)) {
      printf("%d ", allb[j - 1]);
      (*k)--;
      print(allb, i, k);
      break;
    } else
      break;
  }
}
int main() {
  int a, n, i, j, k, all[100000], allb[100000], b;
  for (i = 0; i < 100000; i++) {
    all[i] = 0;
  }
  for (i = 0; i < 100000; i++) {
    allb[i] = 0;
  }
  scanf("%d", &n);
  k = n;
  for (i = 0; i < n; i++) {
    scanf("%d", &all[i]);
    allb[all[i] - 1] = all[i];
    if (all[i] == k) {
      printf("%d ", all[i]);
      k--;
      print(allb, i, &k);
    }
    printf("\n");
  }
}
