Problem in Code

The Code has no errors and is not failing any of the given test cases. However when I submit the code it showed that it failed test cases. Please point out any mistakes if present!
#include
using namespace std;

int max(int a[] , long long n)
{
long long max=0;

 for(long long i=0 ; i<n ; i++)
 {
	 if(a[max]<a[i])
	 {
		 max=i;
	 }
 }

 return(max);

}

int main() {
int a[100000];
long long n;
cout<<"Enter the number of Elements in the array: ";
cin>>n;
cout<<endl;

for(long long i=0 ; i<n ; i++)
{
	cout<<endl<<"Enter element number "<<i+1<<" : ";
	cin>>a[i];
}
int x=max(a,n);
cout<<endl<<"The greatest element is : "<<a[x]<<endl<<"At position : " <<x+1;
return 0;

}

@amangupta ok wait some time let me check it

@amangupta you dont have to print anything else than the answer according to the question here
i have corrected your code https://ide.codingblocks.com/s/233521
i hope your doubt is cleared if yes dont forget to mark the doubt resolved in my doubts section