Given an array of n elements find the count of imbalances in it. Imbalance is arr[i+1] - arr[i] > 1 in sorted array
Example : [4,1,3,2]
for length : 1
subarray 1: [4] => sort it => [4] imbalance : 0
subarray 2: [1] => sort it => [1] imbalance : 0
subarray 3: [3] => sort it => [3] imbalance : 0
subarray 4: [2] => sort it => [2] imbalance : 0
total count of imbalance for imbalance for length 1 is 0 + 0 + 0 + 0 = 0for length : 2
subarrary 1: [4,1] => sort it => [1,4] => imbalance : 1(because 4 - 1 > 1)
subarray 2: [1,3] => sort it => [1,3] => imbalance : 1(because 3 - 1 > 1)
subarray 3 :[3,2] => sort it => [2,3] => imbalance : 0(because 3 - 2 =1)
total count of imbalances for length 2 is 1 + 1 + 0 = 2for length: 3
subarrary 1: [4,1,3] => sort it => [1,3,4] => imbalance : 1(because 3 - 1 > 1)
subarray 2: [1,3,2] => sort it => [1,2,3] => imbalance : 0
total count of imbalances for length 3 is 1 + 0 = 1for length: 4
subarrary 1: [4,1,3,2] => sort it => [1,2,3,4] => imbalance : 0
total count of imbalances for length 4 is 0ans = 0 + 2 + 1 + 0 = 3
Max Array Length : 3 * 10^3