pairing up zero people requires one way .
ways [ 0 ] = 1 NEW_LINE ways [ 2 ] = 1 NEW_LINE for i in range ( 4 , MAX + 1 , 2 ) : NEW_LINE INDENT ways [ i ] = ( ( 1 * ( i - 1 ) * ways [ i - 2 ] ) % mod ) NEW_LINE DEDENT def countWays ( arr , n ) : NEW_LINE