n = int(input())
a = list(map(int, input().split()))
visited = [False] * n
c = 0
for i in range(n):
    if visited[i]:
        continue
    c += 1
    while not visited[i]:
        c += 1
        visited[i] = True
        i = a[i] - 1
print((-1) ** c)