My 1 test case is failing and i am not able to make it where

the problem is maximum power in dp course
#include
using namespace std;
int main() {
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
int currans=1;
int maxans=0;
for(int i=0;i<n;i++)
{
if(i==0)
{
if(arr[i]!=0)
currans=arr[i];
maxans=arr[i];
}
else
{
currans*=arr[i];
maxans=max(maxans,currans);
if(currans==0)
{
currans=1;
}
}

}
cout<<maxans;
return 0;

}
here is my code

@jatingarg17
Your code will not give correct ans for
5
-4 -2 -8 10 2
correct ans should 320, your code is giving 8.

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.