In preparation for an upcoming dance competition, the children are practicing intensely. Just before they are set to perform, they realize their line is not properly arranged. If they head out as they are, the judges will give them a low score due to the lack of neatness.
To avoid losing the competition, they decide to make a local adjustment. The current formation can be viewed as a sequence

of length

, where

represents the height of the

-th child. The neatness of the formation is defined as the length of the longest contiguous subsegment consisting of children with identical heights. They are allowed to perform at most one adjustment operation: Select a subsegment
![[L,R]](https://www.nowcoder.com/equation?tex=%5BL%2CR%5D)
of children. Reorder the children within this subsegment in any order. The time required for this operation is

.
The children want to know: what is the minimum time to achieve the maximum possible neatness using at most one adjustment?