Array max value: one test case failed, my code is correct then also

#include
using namespace std;
int main() {

int n, a[1000000], max=0, index=0;
cin>>n;
if(n<0){
	exit(0);
}
else{

	for(int i=0; i<n; i++){
		cin>>a[i];
		
	}
	//logic for find max value in the array

	for(int i=0;i<n;i++){
		if(max<=a[i]){
			max=a[i];
			index = i;
		}
	}
	cout<<max<<endl;
	
}

return 0;

}

hello @devsumanprasad i am going through your code and i will let you know your mistake .

@devsumanprasad could you please share the question link so that i can see the constraints .

https://online.codingblocks.com/app/player/115623/content/151864/4796/code-challenge

have you understood the constraints clearly ?

@devsumanprasad i have modified your approach for the same question .
you have to initialise the comparator with INT_MIN.
thats will be fine .


please mark this doubt as resolved if your query is cleared .
Happy Learning !!