One test case is not passing .Please help

#include
#include
using namespace std;
#define ll long long
int main() {
ll n;
cin>>n;
ll a[n];
for(ll i=0;i<n;i++) cin>>a[i];
stack s;
s.push(a[0]);
for(ll i=1;i<n;i++){

while(!s.empty()&&s.top()<a[i]){
cout<<a[i]<<" ";
s.pop();
}
s.push(a[i]);
}
while(!s.empty())
{
cout<<-1<<" ";
s.pop();
}

}

in question it is given that array is circular

one test case not passed because you approach does not work on circular array

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.