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