import java.util.Scanner;
public class Hello {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the no of students ");
int n=sc.nextInt();
System.out.println("Enter the age of students ");
int arr[]=new int[n];
for(int i=0;i<n;i++) {
arr[i]=sc.nextInt();
}
for(int i=0;i<n;i++) {
for(int j=i+1;j<n;j++) {
if(arr[i]>arr[j]) {
int temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
System.out.println("Age in ascending order ");
for(int i=0;i<n;i++) {
System.out.print(arr[i]+" ");
}
System.out.println("");
System.out.println("age of the youngest student is "+arr[0]+" and age of the eldest student is "+arr[n-1]);
for(int i=0; i<n ;i++){
int count =1;
while((i < n-1 )&& (arr[i] == arr[i+1]))
{
count++;
i=i+1;
}
System.out.println(" The number of students of " +arr[i]+" "+"is"+" " +count);
}
}
}
public class Hello {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the no of students ");
int n=sc.nextInt();
System.out.println("Enter the age of students ");
int arr[]=new int[n];
for(int i=0;i<n;i++) {
arr[i]=sc.nextInt();
}
for(int i=0;i<n;i++) {
for(int j=i+1;j<n;j++) {
if(arr[i]>arr[j]) {
int temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
System.out.println("Age in ascending order ");
for(int i=0;i<n;i++) {
System.out.print(arr[i]+" ");
}
System.out.println("");
System.out.println("age of the youngest student is "+arr[0]+" and age of the eldest student is "+arr[n-1]);
for(int i=0; i<n ;i++){
int count =1;
while((i < n-1 )&& (arr[i] == arr[i+1]))
{
count++;
i=i+1;
}
System.out.println(" The number of students of " +arr[i]+" "+"is"+" " +count);
}
}
}