Max value in array

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scn=new Scanner(System.in);
int n=scn.nextInt();
int a[]=new int[n];
for(int i=0;i<=n;i++){
a[i]=scn.nextInt();
int max=a[0];
if(a[i]>-1000000000 && a[i]<1000000000)
{

if(a[i]>max)
{
max=a[i];
}
}
System.out.println(max);
}
}
}
the testcases are partially executed where i went wrong there are no errors

@karthik1989photos,
Take input of array from i=0 to i<n. Also, keep max outside the for loop and initialize it with Integer.Min_Value

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.