Wrong answer in one test case of Facto Sum

I am getting Wrong Answer in Test Case #5 in Problem Facto Sum ( Section Arrays)
Can someone point out where I am wrong? Other test cases are showing correct answer.

#include <bits/stdc++.h>
using namespace std;

int main(){

	long long int fact[1001];
	int mod[1001];
	int i;

	fact[0]=0;
	fact[1]=1;



	for(i=0; i<=1000; i++){

		mod[i]= i%107;
	}
	for(i=2; i<=1000; i++)
		{
			fact[i]=(fact[i-1]*mod[i]) % 107;
			//cout<<i<<" "<<fact[i]<<endl;

		}

	long long int sum=0;
	int n,number;
	cin>>n;
	while(n--){

		cin>>number;
		sum=sum+fact[number];
	}

	sum=sum%107;
	cout<<sum<<endl;

	return 0;
}

hi vijyeta
I think that from this method you cant calculate the factorial of the large numbers like 999.
For such numbers you need an array to store the single factorial,it wont even work with long long int.
So wrong answer might me coming for a test case with large number.

Hi! I figured out where I was wrong, I took 0! as 0. I changed it to 1 and it passed. We don’t need to calculate the factorial of such large numbers. Use mod properties to calculate their mod with 107.

can you explain your method?

https://ide.codingblocks.com/#/s/16133
you can refer this code
using mode property in loop of factorial we can calculate 1000 factorial so no need to do anything extra just find fact using mod property and then just make it sum and cout

But why is it working?
We are taking mod with 107,then acc. to the function the ans should be 0 for every multiple of 107.
How is it correct then??

it is a prime no never modulus be 0