Input: N = 8, A[] = {2, 0, 2, 3, 0, 3, 2, 2}
Output: 4
Explanation: First subarray -> {2, 0, 2, 3, 0, 3}.
In this subarray, swap indices 3 and 4. We get {2, 0, 3, 2, 0, 3} which is the repetition of {2, 0, 3} twice.
Second subarray -> {2, 0, 2, 3, 0, 3, 2, 2}.
Swap the following pairs of indices :
2 and 3 -> {2, 2, 0, 3, 0, 3, 2, 2}
5 and 7 -> {2, 2, 0, 3, 2, 3, 0, 2}
6 and 8 -> {2, 2, 0, 3, 2, 2, 0, 3}
The array becomes a repetition of {2, 2, 0, 3}.
Similarly, the rest of the subarrays are {0, 2, 3, 0, 3, 2} and {2, 2}.
Input: N = 15, A[] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7}
Output: 29