Question and Answer from L4-M2
T = int(input())
for _ in range(T):
N = int(input())
A = list(map(int, input().split()))
magical_count = 0
for start in range(N):
visited = set()
pos = start
while True:
if pos in visited:
# If we visit the same box again before returning to start, not magical
break
visited.add(pos)
pos = (pos + A[pos] + 1) % N # Move: eat current box, skip A[pos], land next
if pos == start:
# Came back to start — it's magical!
magical_count += 1
break
print(magical_count)