frequency count of all the elements
for ( i = 0 ; i < n ; i ++ ) count [ arr [ i ] ] += 1 ; var ans = 0 ; for ( i = 0 ; i < n ; i ++ ) for ( j = 0 ; j < n ; j ++ ) { if ( arr [ i ] < arr [ j ] ) continue ; if ( Math . abs ( arr [ i ] - arr [ j ] ) % 2 == 1 ) continue ;