Doesnt pass all test xases

#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;

int a[n]={0};
for(int i=0;i<n;i++)
{
  cin>>a[i];
}

int q;
cin>>q;

for(int i=0;i<q;i++)
{
	int x;
	cin>>x;
	auto it= lower_bound(a,a+n,x);
	if(it-a ==n)
	{
		cout<<"-1"<<" "<<"-1"<<endl;
		continue;
	}
	else{
		cout<< it-a <<" ";
	}

	auto ub= upper_bound(a,a+n,x);
	cout<<(ub-a)-1<<" "<<endl;
}

}

@the.shubham.sri
You have not considered the case when element doesn’t exist and is smaller than ar[n-1].
Considered this testcase
5
2 3 5 6 9
3
1
4
10
Output should be:
-1 -1
-1 -1
-1 -1
but your code is giving something else

hey TA wanna ask that if my problem got partially correct should i be given any marks for that in hackerblocks

@the.shubham.sri
yes you will get partial mark for it but try to solve problem completely.