Modified to sort by abolute values
static void findMinSum ( int [ ] arr , int n ) { for ( int i = 1 ; i < n ; i ++ ) { if ( ! ( Math . Abs ( arr [ i - 1 ] ) < Math . Abs ( arr [ i ] ) ) ) { int temp = arr [ i - 1 ] ; arr [ i - 1 ] = arr [ i ] ; arr [ i ] = temp ; } } int min = Int32 . MaxValue ; int x = 0 , y = 0 ; for ( int i = 1 ; i < n ; i ++ ) {