## Editorial for Robot

Remember to use this editorial

**only**when stuck, and**not to copy-paste code from it**. Please be respectful to the problem author and editorialist.**Submitting an official solution before solving the problem yourself is a bannable offence.**The power of a robot is simply the multiplication of the prime numbers which can be extracted from the $N$ numbers. For each number, we can calculate all the primes which make that number.

Primes of \(X\) can be calculated by iterating from 2 to the **square root of \(X\)**. For each iteration, it can be checked if \(X\) can be divided by the number or not. If the number can be divided it's prime and if \(X\) can be further divided to the number we divide till it cannot be divided. If the number cannot be divided by any numbers, then \(X\) is a prime number and we insert it into our set.
For example for a spell of power 18.

- First check for 2. Since it can be divided by \(X\) is 9 and we insert 2 into the set. 2 cannot divide 9. So we check for 2+1=3.
- 9 can be divided by 3 twice. 3 Will be inserted into the list and since \(X\) is now 1, we can stop the process.

After all those numbers put in a set, we can simply take multiplication of all of them. (Not forgetting the modulo)

```
#include <bits/stdc++.h>
using namespace std;
const int md = (int) 1e9 + 7;
const int siz = 300005;
long long arr[siz];
long long n, m, k, l, x;
set<long long> s;
void addPrimes(long long x){
int i=2;
while(x!=1){
while(x%i==0){
x/=i;
s.insert(i);
}
if(sqrt(x)<i) {
s.insert(x);
break;
}
i++;
}
}
int main(){
cin>>n;
for(int i=0;i<n;i++){
cin>>x;
addPrimes(x);
}
long long res=1;
for(auto c:s){
res*=c;
res%=md;
}
cout<<res;
}
```