-
Notifications
You must be signed in to change notification settings - Fork 16
/
find product
37 lines (30 loc) · 835 Bytes
/
find product
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
You have been given an array A of size N consisting of positive integers. You need to find and print the product of all the number in this
array Modulo 109+7.
Input Format:
The first line contains a single integer N denoting the size of the array. The next line contains N space separated integers denoting the
elements of the array
Output Format:
Print a single integer denoting the product of all the elements of the array Modulo 109+7.
Constraints:
1≤N≤103
1≤A[i]≤103
SAMPLE INPUT
5
1 2 3 4 5
SAMPLE OUTPUT
120
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n; cin>>n;
long long a[n],i,prod=1;
for(i=0;i<n;i++)
{
cin>>a[i];
prod = (prod*a[i]) % 1000000007;
}
cout<<prod;
}