Construct hash for negative elements
for ( int i = 0 ; i <= n - 1 ; i ++ ) { if ( arr [ i ] < 0 ) { if ( hashNegative . ContainsKey ( Math . Abs ( arr [ i ] ) ) ) { hashNegative [ Math . Abs ( arr [ i ] ) ] += 1 ; } else { hashNegative . Add ( Math . Abs ( arr [ i ] ) , 1 ) ; } } }