Cacluating inverse_product array .
function calculate_inverse_product ( A , N , P ) { inverse_product [ 0 ] = modInverse ( pre_product [ 0 ] , P ) ; for ( let i = 1 ; i < N ; i ++ ) inverse_product [ i ] = modInverse ( pre_product [ i ] , P ) ; }