Bikers Problem-Dynamic Programming

this code gives negative output for n=87,can you tell the mistake ?

#include
using namespace std;

int main() {
int t,n;
cin>>t;
while(t–)
{
cin>>n;
long a[n+1];
a[0]=1;
a[1]=1;
for(int i=2;i<=n;i++)
{
a[i]=a[i-1] + (i-1)*a[i-2];
// cout<<a[i]<<endl;
}
cout<<a[n]<<endl;
}
return 0;
}

hey @S19APP-PP0060, i compile your code here and it is giving positive answer only https://ide.codingblocks.com/s/110424

Check for some value, say 84. It gives a negative output

hey @S19APP-PP0060, yes it can give negative answer when maximum positive range of long is over.

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.