def cycle(s):
nums = [int(i) for i in s.split(' ')]
n = len(nums)
nc = 0
check = [1 for i in range(n)]
ct = ''
for i in range(n):
st = '('
j = i
while (check[j] == 1):
check[j] = 0
st += str(j) + ' '
j = nums[j]
else:
if (len(st)>1):
st += ')'
print(st)
nc += 1
return nc
print(cycle(input()))
def cycle(s):
nums = [int(i) for i in s.split(' ')]
n = len(nums)
nc = 0
check = [1 for i in range(n)]
ct = ''
for i in range(n):
st = '('
j = i
while (check[j] == 1):
check[j] = 0
st += str(j) + ' '
j = nums[j]
else:
if (len(st)>1):
st += ')'
print(st)
nc += 1
return nc
print(cycle(input()))
輸入第一行是人數