Making sure that all elements are distinct array elements and an element is not considered more than once .
pair p = mp [ X - sum ] ; if ( p . first != i && p . first != j && p . second != i && p . second != j ) { Console . Write ( arr [ i ] + " , ▁ " + arr [ j ] + " , ▁ " + arr [ p . first ] + " , ▁ " + arr [ p . second ] ) ; return ; } } } } }