Number of Squareful Arrays

Count permutations of an integer array where every adjacent pair sums to a perfect square. Handle duplicates by counting each distinct permutation once.

Examples
Input: [1,17,8]
Output: 2
Hints

Number of Squareful Arrays

Count permutations of an integer array where every adjacent pair sums to a perfect square. Handle duplicates by counting each distinct permutation once.