Product of the Others
For every position print the product of ALL OTHER elements, modulo 109+7. Division is not available (elements may be 0).
Input: the first line has N; the second line has N integers.
Output: N integers: for each i, ∏j≠i aj mod 109+7 (values reduced to [0, mod)).
Constraints:
- 1 ≤ N ≤ 105
- -100 ≤ ai ≤ 100
Sample Tests
Input 1
4 1 2 3 4
Output 1
24 12 8 6
Input 2
2 0 5
Output 2
5 0
Discussion (opens after you solve — no spoilers before)
No comments yet.