n = int(input()) entry = input().split() entry = list(map(int, entry)) counter = 0 for i in range(1, n-1, 2): if entry[i]>=entry[i+1] or entry[i]>=entry[i-1]: entry[i] = min(entry[i+1], entry[i-1])-1 counter+=1 if entry[n-1]>=entry[n-2] and entry[n-1]%2==0: entry[n-1]=entry[n-2]-1 counter+=1 print(counter)
1 2 3 4 5 6 7 8 9 10 11 12 | n = int(input()) entry = input().split() entry = list(map(int, entry)) counter = 0 for i in range(1, n-1, 2): if entry[i]>=entry[i+1] or entry[i]>=entry[i-1]: entry[i] = min(entry[i+1], entry[i-1])-1 counter+=1 if entry[n-1]>=entry[n-2] and entry[n-1]%2==0: entry[n-1]=entry[n-2]-1 counter+=1 print(counter) |