N = input() Line = map(int, input().split(' ')) Line2 = [x-i-1 for (i, x) in enumerate(Line)] print(max(Line2))