generating all subsets
for ( int i = 1 ; i < ( 1 << N ) ; i ++ ) { List < int > temp = new List < int > ( ) ; for ( int j = 0 ; j < N ; j ++ ) { if ( ( i & ( 1 << j ) ) != 0 ) { temp . Add ( A [ j ] ) ; } } int flag = 0 ;