# Number Of Sequence

Posted: 18 Jun, 2021

Difficulty: Hard

#### A sequence is called nice by a coding ninja if the following conditions are met:

```
0 <= ‘ARR’[k] <= k
‘ARR’[k] = ‘ARR’[m] mod k, for all pairs of k,m such that k divides m.
```

#### You are given a sequence of integers ‘ARR’ where some numbers may be -1. Find and print the number of nice sequences you can create by changing each -1 to a non-negative integer. As this number can be quite large, your answer must be modulo it by 10 ^ 9 + 7.

#### For example:

```
Given ‘N’ = 3,
'A' = {0, -1, -1}
Then the answer is 6 because following sequences are possible:[0, 0, 0], [0, 1, 0], [0, 1, 1], [0, 1, 2], [0, 0, 1], [0, 0, 2].
```

##### Input format:

```
The first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of each test case contains a single integer, ‘N,’ where ‘N’ is the number of elements of the array.
The second line of each test case contains ‘N’ space-separated integers, denoting the array elements.
```

##### Output Format :

```
For each test case, You are supposed to return the total number of nice arrays that can be formed.
```

##### Note:

```
You are not required to print the expected output; it has already been taken care of. Just implement the function.
```

##### Constraints:

```
1 <= ‘T’ <= 10
1 <= ‘N’ <= 3000
0 <= 'ARR[i]’ <= 10 ^ 6
Time Limit: 1 sec.
```