Guest User

Untitled

a guest
Nov 6th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.22 KB | None | 0 0
  1. def main():
  2. N = int(input())
  3. A = list(map(int, input().split()))
  4. ans = 0
  5. for i in range(N):
  6. if A[A[i]-1] == i + 1:
  7. ans += 1
  8. print(ans//2)
  9.  
  10.  
  11. if _name_ == "_main_":
  12. main()
Add Comment
Please, Sign In to add comment