In hackerblock question i.e Facto Sum

please tell me why my submission is not successful, my code only passes 2 test cases out of 6.

Here is my code:-

using namespace std;
int facto(int n){
int fact=1;
while(n>0){
fact*=n;
n–;
}
return fact;
}
int main()
{
int n; cin>>n;
int arr[n],sum=0;
for(int i=0; i<n; i++){
cin>>arr[i];
sum += facto(arr[i]);
}

cout<<sum%107;

return 0;
}

@sonu28sharma99 You must try to solve this problem using matrix exponential method of Fibonacci sum.
Google it and you would learn even more.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.