Testcase 4 is not showing output ,,but when i use it for custom input it is showing correctly

#include
#include
using namespace std;
int main() {
int n;
cin>>n;
int a[n]={0};
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int target = 0;
cin>>target;
sort(a,a+n-1);
int *l=&a[0];
int *r=&a[n-1];
while(*l<*r)
{
if(*l+*r==target)
{
cout<<*l<<" and "<<*r;
r = r - 1;
l = l + 1;
}
else if(*l+*r>target)
{ r = r -1;}
else if(*l+*r<target)
{
l = l + 1;
}
else
{}
cout<<endl;
}
return 0;
}

@shakul hey shakul please share your code through cb.lk/ide and paste your code on this short link ide and press save button. it generate a link please generate this link here.