Montone squared Clustering with data lists

I have two lists from which i need to find a minimised monotone Grouping of k.

C(j,l) denotes the min objective function value of the list (aj,aj+1) im trying to express the value as C(j,l) using C(K,l-1) for k = j+1,j+2

here is a snap of my code, can somebody tell me whats wrong why is it not monotone?

https://imgur.com/a/SNauG.jpg