Given an array of n integer elements. At a single moment we can delete a subarray if every element of this subarray is equal to one another. Doing so give us the points equal to (size of subarray)^2. We have to completely eliminate the array and also maximise the sum of points scored. How to solve this problem?
Eg: Array = [1,1,1,2,2,1]
Answer = 20