Find two adjacent indices to take difference
if ( index == 0 ) res = min ( res , abs ( num - right [ index ] ) ) ; else if ( index == right . size ( ) ) res = min ( res , abs ( num - right [ index - 1 ] ) ) ; else res = min ( res , min ( abs ( num - right [ index - 1 ] ) , abs ( num - right [ index ] ) ) ) ; }