slow but correct solution of LeadCyclSeq