int input kv29 kv kpar buf int input for in range for in range int inp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
n = int(input())
kv29 = 0
kv = 0
kpar = 0
buf = [int(input()) for i in range(4)]
for i in range(4, n):
a = int(input())
b = buf[0]; buf.pop(0); buf.append(a); kv += 1
if a % 29 == 0:
kpar += kv
elif b%29:
kpar += n - i
kv29 += 1
else:
kpar += kv29
print(kpar)