
EXAMPLE

For example, in the sequence 0, 1, 2, 1, 0, 1, 2 (length 7) consisting of integers in the range [0..2], no two adjacent segments of equal length (e.g., 0, 1, 2 and 1, 0, 1) have the same sum modulo 3. There is also no longer sequence with this property, hence a(3) = 7.
Lexicographically earliest solutions represented as digit strings.
n a(n)
1 1 0
2 3 010
3 7 0102010
4 16 0130102013101201
5 33 010214243213143040102142432131430
6 35 01024021240241402401024021240241402
7 47 01021614636032312426404301021614636032312426404
8 61 0120135461316135364357463523745020571465756571764713467127313
(End)
