Facto sum two test are not passing

Problem Link https://online.codingblocks.com/player/2612/content/786
#include
using namespace std;
long long factorial(long long num){
long long fact = 1;
for(long long i = num; i >=1 ;i–)
fact *= i;
return fact;
}
int main() {
long long n,res=0;
cin>>n;
long long arr[15];
for(long i =0 ;i < n; i++){
cin>>arr[i];
}
for(long i =0 ;i < n; i++){
res += (factorial(arr[i])%107);

 }
 cout<<res<<endl;
  
return 0;

}

Hey ! ur code seems fine but suppose you are given one element as 100 then your factorial function cannot be able to calculate its factorial so you need to take modulo in with 107 in every iteration inside factorial function . Got it ??

Use properties of Modulo % for finding factorial as well while adding.