#include <bits/stdc++.h>
int store_ar[500000];
int main() {
  int stack_ar[500000], n, i, pivot;
  scanf("%d", &n);
  pivot = n;
  for (i = 0; i < n; ++i) {
    scanf("%d", &stack_ar[i]);
  }
  for (i = 0; i < n; ++i) {
    store_ar[stack_ar[i]] = stack_ar[i];
    if (stack_ar[i] == pivot) {
    again:
      printf("%d ", pivot);
      --pivot;
      if (store_ar[pivot] != 0)
        goto again;
      else
        printf("\n");
    } else {
      printf("\n");
    }
  }
  return 0;
}
