Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
N = int(input())
A = [int(x) for x in input().split()]
t = 0
ans = 0
for i in range(N):
if i == 0 or A[i-1] < A[i]:
t += 1
else:
ans += t*(t+1)//2
t = 1
ans += t*(t+1)//2
print(ans)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment