What is my mistake? where does my solution fails?

Problem was to find the factorial of the small integer taking test cases T

</>
include
using namespace std;

int fact(int n){
if(n>1)
{
int smalloutput =fact(n-1);
int output = n* smalloutput;
return output;
}
if(n<0)
{
int smalloutput =fact(-n-1);
int output = -n* smalloutput;
return -output;
}
else
{return 1;}

}
int main() {
int t;
cin>>t;
int a[t];
for (int i=0; i<t;i++)
{
cin>>a[i];
}
for (int i=0; i<t;i++){
int x = a[i];
cout<<fact(x)<<endl;
}

return 0;

}