n = int(input()) A = list(map(int, input().split())) C = [(0, 0)] for i in range(n - 1, -1, -1): if i == n - 1: prev_b = A[i] seq_n = 1 else: if A[i] == prev_b: seq_n += 1 else: C.append((prev_b, seq_n)) prev_b = A[i] seq_n = 1 if i == 0: C.append((prev_b, seq_n)) m = len(C) ANS = [0 for _ in range(A[0])] curr_b = n row_n = 0 cidx = 0 for i in range(1, m): block_n, decrease_n = C[i] for _ in range(block_n - row_n): ANS[cidx] = curr_b cidx += 1 row_n = block_n curr_b -= decrease_n print(*ANS)