import java.util.Scanner;
public class Arraymax
{
static Scanner scn=new Scanner(System.in);
public static void main(String [] args)
{
int[] array=takeinput();
display(array);
System.out.println("Largest element in the array is "+maxinArray(arr));
}
public static int[] takeinput()
{
System.out.println("Enter the size of the array ");
int n=scn.nextInt();
int[] arr=new int[n];
for(int i=0;i<arr.length;i++)
{
System.out.println("Enter the value for "+i+" index");
arr[i]=scn.nextInt();
}
return arr;
}
public static void display(int[] arr)
{
System.out.println("Elements of the arrasy are ");
for(int i=0;i<arr.length;i++)
{
System.out.println(arr[i]);
}
}
public static int maxinArray(inr[] arr)
{
// initialising max to infinity
int max= Integer.MIN_VALUE;
for(int i=0;i<arr.length;i++)
{
if(arr[i]>max)
{
max=arr[i];
}
}
return max;
}
}