Run error in one of the test case

#include
using namespace std;
int main()
{ int n;
int a[10],l[10],r[10];
int w=0;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
l[0]=a[0];
r[n-1]=a[n-1];
for(int i=1;i<n;i++)
{
l[i]=max(a[i],l[i-1]);
r[n-i-1]=max(a[n-i-1],r[n-i]);
}
for(int i=0;i<n;i++)
{
w+=min(l[i],r[i])-a[i];
}
cout<<w;

return 0;

}

@bhavyajain hey bhavya increase size of the array to 100

Hey Bhavya,
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.