Can anyone please let me know whats wrong in the code below. Continuously receiving wrong answer message.
import java.util.;
import java.lang.;
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner s = new Scanner(System.in);
int a[] = new int[10000];
int n = s.nextInt();
int i,p=0;
for(i=0;i<n;i++)
{
a[i] = s.nextInt();
}
for(i=0;i<n;i++)
{
if(a[i]==42)
{
p=i;
}
}
for(i=0;i<p;i++)
{
System.out.println(a[i]);
}
}
}