_ = input() a = list(map(int, input().split(' '))) t = a[-1] for n in reversed(a[:-1]): if t == 1: t = n elif n >= t: t -= 1 print(t)