n = int(input()) permutation = list(map(int, input().split())) visited = [False] * n count = 0 for i in range(1, n + 1): if not visited[i - 1]: current = i cycle_length = 0 while not visited[current - 1]: visited[current - 1] = True current = permutation[current - 1] cycle_length += 1 count += (cycle_length - 1) sign = 1 if count % 2 == 0 else -1 print(sign)