------
## 最终结论
```python
import itertools

def num_squareful_permutations(A):
    def is_perfect_square(n):
        if n < 0:
            return False
        root = int(n**0.5)
        return root * root == n

    A.sort()
    result = set()  # Use a set to avoid duplicates
    for perm in itertools.permutations(A):
        if all(is_perfect_square(perm[i] + perm[i + 1]) for i in range(len(perm) - 1)):
            result.add(perm)

    return len(result)
```