Calculate the Closest value for every subarray arr [ i - 1 : n ]
for ( int i = 1 ; i <= n ; i ++ ) ans = RetClose ( arr [ i - 1 ] + MinDiff ( i , arr [ i - 1 ] , arr , n ) , ans , 0 ) ; cout << ans << endl ; }