Count arrays that are really unique
Haskell
import Control.Monad (replicateM)
import Data.List (tails)
import qualified Data.IntSet as S
import qualified Data.Map.Strict as M
import qualified Data.Vector.Unboxed as V
import Data.Vector.Unboxed.Mutable (write)
import System.Environment (getArgs)
import Control.Parallel.Strategies

orig:: Int -&gt; Int -&gt; M.Map S.IntSet (Maybe Int)
orig n s = M.fromListWith (\ _ _ -&gt; Nothing) 
               [(sums l, Just $! head l) | 
                   l &lt;- replicateM n [s, s+1],
                   l &lt;= reverse l ]

sums :: [Int] -&gt; S.IntSet
sums l = S.fromList [ hi-lo | (lo:r) &lt;- tails $ scanl (+) 0 l, hi &lt;- r ]

construct :: Int -&gt; Int -&gt; S.IntSet -&gt; [Int]
construct n start set =
   setmax `seq` setmin `seq` setv `seq`
   [ weight r | r &lt;- map (start:) $ constr (del start setlist)
                                           (V.singleton start)
                                           (n-1)
                                           (setmax - start),
                r &lt;= reverse r ]
  where
    setlist = S.toList set
    setmin = S.findMin set
    setmax = S.findMax set
    setv = V.modify (\v -&gt; mapM_ (\p -&gt; write v p True) setlist)
                    (V.replicate (1+setmax) False)

    constr :: [Int] -&gt; V.Vector Int -&gt; Int -&gt; Int -&gt; [[Int]]
    constr m _ 0 _ | null m    = [[]]
                   | otherwise = []
    constr m a i x =
         [ v:r | v &lt;- takeWhile (x-(i-1)*setmin &gt;=) setlist,
                 V.all (V.unsafeIndex setv . (v+)) a,
                 let new = V.cons v $ V.map (v+) a,
                 r &lt;- (constr (m \\\ new) $! new) (i-1) $! (x-v) ]
 
del x [] = []
del x yl@(y:ys) = if x==y then ys else if y&lt;x then y : del x ys else yl

(\\\) = V.foldl (flip del)

weight l = if l==reverse l then 1 else 2

count n s = sum ( map value [ x | x@(_, Just _) &lt;- M.toList $ orig n s]
                      `using` parBuffer 128 rseq )
  where 
    value (sms, Just st) = uniqueval $ construct n st sms
    uniqueval [w] = w
    uniqueval _   = 0


main = do
  [ n ] &lt;- getArgs
  mapM_ print ( map (count (read n)) [1..9]
                    `using` parBuffer 2 r0 )

The orig function creates all the lists of length n with entries s or s+1, keeps them if they come before their reverse, computes their sublist sums and puts those in a map which also remembers the first element of the list. When the same set of sums is found more than once, the first element is replaced with Nothing, so we know we don't have to look for other ways to get these sums.
The construct function searches for lists of given length and given starting value that have a given set of sublist sums. Its recursive part constr follows essentially the same logic as this, but has an additional argument giving the sum the remaining list entries need to have. This allows to stop early when even the smallest possible values are too big to get this sum, which gave a massive performance improvement. Further big improvements were obtained by moving this test to an earlier place (version 2) and by replacing the list of current sums by a Vector (version 3 (broken) and 4 (with additional strictness)). The latest version does the set membership test with a lookup table and adds some more strictness and parallelization.
When construct has found a list that gives the sublist sums and is smaller than its reverse, it could return it, but we are not really interested in it. It would almost be enough to just return () to indicate its existence, but we need to know if we have to count it twice (because it is not a palindrome and we'll never handle its reverse). So we put 1 or 2 as its weight into the list of results.
The function count puts these parts together. For each set of sublist sums (coming from orig) that was unique amongst the lists containing only s and s+1, it calls value, which calls construct and, via uniqueval, checks if there is only one result. If so, that is the weight we have to count, otherwise the set of sums was not unique and zero is returned. Note that due to lazyness, construct will stop when it has found two results.
The main function handles IO and the loop of s from 1 to 9.
Compiling and Running
On debian this needs the packages ghc, libghc-vector-dev and libghc-parallel-dev. Save the program in a file prog.hs and compile it with ghc -threaded -feager-blackholing -O2 -o prog prog.hs. Run with ./prog &lt;n&gt; +RTS -N where &lt;n&gt; is the array length for which we want to count the unique arrays.