Problems > Product Modulo 1e9+7

Product Modulo 1e9+7

Difficulty: 1100 2000 ms 128 MB

math

Print the product of all values modulo 1 000 000 007. Values may be negative; the printed result must be in [0, 109+6].

Input: the first line has an integer N; the second line has N integers separated by spaces.

Output: the product of the N values modulo 1 000 000 007 (non-negative).

Constraints:

  • 1 ≤ N ≤ 2000
  • −109 ≤ ai ≤ 109

Sample Tests

Input 1
3
2 3 4
Output 1
24
Input 2
2
-2 5
Output 2
999999997

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.