This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
n = int(input())
lis = list(map(int, input().split()))
a = [0]
b = [0]
for i in range(len(lis)-1):
a.append(a[-1] + max(0,lis[i]-lis[i+1]+1))
lis.reverse()
for i in range(len(lis)-1):
b.append(b[-1] + max(0,lis[i]-lis[i+1]+1))
b.reverse()
print(min([max([a[i],b[i]]) for i in range(len(a))]))
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |