If elements of any pair are equal and their frequency is not divisible by 2 update the isArrayPossible variable to false and break through the loop
if ( i . first == s1 - i . first ) { if ( mp [ i . first ] % 2 != 0 ) { isArrayPossible = false ; break ; } }