there will be no middle element so for each a [ i ] there will be 2 ways
var start = 1 , endd = n - 1 ; for ( var i = 1 ; i <= endd ; i = i + 2 ) { if ( cnt [ i ] !== 2 ) return 0 ; } var ways = 1 ; for ( var i = start ; i <= endd ; i = i + 2 ) { ways = ways * 2 ; } return ways ; } return - 2147483648 ; }