tlist[n_]:=Module[{t1=Range[3,n-1],t2={1,n,2}},Do[If[t1=={},Break[]];If[t2[[1]]>t2[[-1]],AppendTo[t2,t1[[-1]]],PrependTo[t2,t1[[-1]]]];t1=Delete[t1,-1];If[t1=={},Break[]];If[t2[[1]]>t2[[-1]],PrependTo[t2,t1[[1]]],AppendTo[t2,t1[[1]]]];t1=Delete[t1,1];,n];If[n>=3,RotateLeft[t2,Floor[n/2]-1],Range[n]]]

tlist@20

ts[n_]:=Module[{list=tlist[n]},Append[Table[list[[i]]+list[[i+1]],{i,n-1}],list[[n]]+list[[1]]]]

ts[20]-21

Flatten@Position[Flatten@Table[Position[tlist@n,1],{n,100}],2]

t[list_]:=Sum[list[[i]]list[[i+1]],{i,Length[list]-1}]+list[[Length[list]]]list[[1]]

t[tlist[9]]

Table[(((n^3)/6)+((n^2)/2)+(5/6)n-((3+(((-1))^n))/4)),{n,100}]

ts[n]-n-1

n=19;
list1={0,1,0,1,-1,1,-1,2,-1,1,-1,1,-1,1,-1,1,-1,1,-1};
Join[Table[(Subscript[x, i])+(Subscript[x, i+1])==list1[[i]]+n+1,{i,n-1}],{(Subscript[x, n])+(Subscript[x, 1])==list1[[n]]+n+1}]
Solve[%,Table[(Subscript[x, i]),{i,n}]]
Sort[Table[(Subscript[x, i]),{i,n}]/.%[[1]]]