a die simulator generate random number 1 6 roll you introduce constraint generator roll number rollmaxi 1indexed consecutive timesgiven array integer rollmax integer n return number distinct sequence obtain exact n roll since answer large return modulo 109 7two sequence consider different element differ Example 1input n 2 rollmax 112223output 34explanation there 2 roll die constraint die 6 6 36 possible combination in case look rollMax array number 1 2 appear consecutively sequence 11 22 occur final answer 362 34example 2input n 2 rollMax 111111output 30example 3input n 3 rollmax 111223output 181 constraints1 n 5000rollmaxlength 61 rollMaxi 15