Solution: Magic Sequences

The code...

declare
fun {MagicSequence N}
   Cs = {List.number ~1 N-2 1}
in
   proc {$ S}
      {FD.tuple sequence N 0#N-1 S}
      {For 0 N-1 1
        proc {$ I} {FD.exactly S.(I+1) S I} end}
      %redundant constraints
      {FD.sum S '=:' N}
      {FD.sumC Cs S '=:' 0}

      {FD.distribute ff S}
   end
end

{ExploreOne {MagicSequence 10}}
For N=10, we get
1#sequence(6 2 1 0 0 0 1 0 0 0)

Markus Löckelt