Count cyclically self-describing lists Cyclically self-describing lists

A list \$L\$ of positive integers is cyclically self-describing, if the following conditions hold.


\$L\$ is nonempty.
The first and last elements of \$L\$ are different.
If you split \$L\$ into runs of equal elements, the element of each run equals the length of the next run, and the element of the last run equals the length of the first run.


For example, consider \$L = [1,1,1,2,3,3,1,1,1,3]\$.
It is nonempty, and the first and last elements are different.
When we break it into runs, we get \$[[1,1,1],[2],[3,3],[1,1,1],[3]]\$.


The first run is a run of \$1\$s, and the length of the next run, \$[2]\$, is \$1\$.
The second run is a run of \$2\$s, and the length of the next run, \$[3,3]\$, is \$2\$.
The third run is a run of \$3\$s, and the length of the next run, \$[1,1,1]\$, is \$3\$.
The fourth run is a run of \$1\$s, and the length of the next run, \$[3]\$, is \$1\$.
Finally, the last run is a run of \$3\$s, and the length of the first run, \$[1,1,1]\$, is \$3\$.


This means that \$L\$ is a cyclically self-describing list.

For a non-example, the list \$[3,2,2,2,1,4,1,1,1]\$ is not cyclically self-describing, since a run of \$2\$s is followed by a run of length \$1\$.
The list \$[2,2,4,4,3,3,3,3]\$ is also not cyclically self-describing, since the last run is a run of \$3\$s, but the first run has length \$2\$.

The Task

In this challenge, your input is an integer \$n \geq 1\$.
Your output shall be the number of cyclically self-describing lists whose sum equals \$n\$.
For example, \$n = 8\$ should result in \$4\$, since the cyclically self-describing lists whose sum is \$8\$ are \$[1,1,1,1,4]\$, \$[1,1,2,1,1,2]\$, \$[2,1,1,2,1,1]\$ and \$[4,1,1,1,1]\$.
The lowest byte count wins, and other standard code-golf rules apply.

Here are the correct output values for inputs from \$1\$ to \$50\$:

1 -&gt; 0
2 -&gt; 0
3 -&gt; 0
4 -&gt; 2
5 -&gt; 0
6 -&gt; 2
7 -&gt; 0
8 -&gt; 4
9 -&gt; 0
10 -&gt; 6
11 -&gt; 6
12 -&gt; 12
13 -&gt; 0
14 -&gt; 22
15 -&gt; 10
16 -&gt; 32
17 -&gt; 16
18 -&gt; 56
19 -&gt; 30
20 -&gt; 96
21 -&gt; 56
22 -&gt; 158
23 -&gt; 112
24 -&gt; 282
25 -&gt; 198
26 -&gt; 464
27 -&gt; 364
28 -&gt; 814
29 -&gt; 644
30 -&gt; 1382
31 -&gt; 1192
32 -&gt; 2368
33 -&gt; 2080
34 -&gt; 4078
35 -&gt; 3844
36 -&gt; 7036
37 -&gt; 6694
38 -&gt; 12136
39 -&gt; 12070
40 -&gt; 20940
41 -&gt; 21362
42 -&gt; 36278
43 -&gt; 37892
44 -&gt; 62634
45 -&gt; 67154
46 -&gt; 108678
47 -&gt; 118866
48 -&gt; 188280
49 -&gt; 209784
50 -&gt; 326878
Haskell, 75 bytes

Thanks Ørjan for saving one byte!



g n=sum[x#n|x&lt;-[1..n],let a#n=sum$[b#(n-a*b)|b&lt;-[1..n],a/=b]++[0^n^2|a==x]]


Try it online!

The problem is equivalent to:

How many ways can \$n\$ be written as \$\sum_{i=0}^ka_ia_{i+1}\$ with \$a_i\in\mathbb N,a_i\neq a_{i+1},a_0=a_k\$