Sort game(no such element exception)

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Emplyee
{
String name;
int salary;
public Emplyee(String name,int salary)
{
this.name=name;
this.salary=salary;
}
}
class SortbySalary implements Comparator
{

@Override
public int compare(Emplyee o1, Emplyee o2) {

  return o2.salary-o1.salary;
}

}
public class SortGame {

public static void main(String[] args) {
 
	Scanner sc=new Scanner(System.in);
	int max=sc.nextInt();
    int n=sc.nextInt();
	Emplyee a[]=new Emplyee[n];
	  for(int i=0;i<n;i++)
	  {
		String name=sc.next();
		int salary=sc.nextInt();
		Emplyee e=new Emplyee(name, salary);
		a[i]=e;
	  }
	 Arrays.sort(a,new SortbySalary());
	 int sum=0;
	 for(int i=0;i<n;i++)
	 {
		 if(a[i].salary>=max)
		 {
		 
			 
			 if(i+1<n&&a[i].salary==a[i+1].salary)
			 {
				 if(a[i].name.compareTo(a[i+1].name)<0)
				 {
					 
	         System.out.println(a[i].name+" "+a[i].salary);

			  System.out.println(a[i+1].name+" "+a[i+1].salary);
			  
		      }
		   else
		   {
		   System.out.println(a[i+1].name+" "+a[i+1].salary);

			  System.out.println(a[i].name+" "+a[i].salary);			 
			 }
				 i++; 
			 }
			 else
			 {
				  System.out.println(a[i].name+" "+a[i].salary);			 
						
			 }
				 
		 
		 }
		 
	 }
	 
	  
	
	
}

}
what is the problem with this code
it is showing no such elemnt exception

Please post the link to the question so that I can help you properly.
And instead of copying the code directly here, please save it on the ide, https://ide.codingblocks.com/
and then share that link here, as it is easier to debug and find mistakes.

If you wish to learn more about the “no such element exception”, you can go through following links:

A common mistake that students usually do
You need to write
scn.nextLine();
when you are taking input of string just after an integer

like
int t = scn.nextInt();
scn.nextLine();
String s = scn.nextLine();

This is required because when you press enter after the integer, the “\n”, character gets stored in the buffer and is considered as String s, if the line scn.nextLine(); is not mentioned.
Writing scn.nextLine(); this consumes the “\n” character and the string entered goes to s, as is required.

import java.util.*;
public class Main {
public static void main(String args[]) {
// Your Code Here
Scanner sc=new Scanner(System.in);
int x=sc.nextInt();
int n=sc.nextInt();
String s[]=new String[n];
int a[]=new int[n];
for(int i=0;i<n;i++){
s[i]=sc.next();
a[i]=sc.nextInt();
}
for (int counter = 0; counter < a.length - 1; counter++) {

		for (int j = 0; j < a.length - 1 - counter; j++) {

			if (a[j] < a[j + 1]) {
				int temp = a[j];
                String str = s[j];
				a[j] = a[j + 1];
                s[j]   =   s[j + 1];
				a[j + 1] = temp;
                s[j + 1]   = str;
			}
		}
	}
    for(int i=0;i<a.length-1;i++){
       if(a[i]==a[i+1]){
           int val=s[i].compareTo(s[i+1]);
           if(val>0){
               String temp2=s[i];
               s[i]=s[i+1];
               s[i+1]=temp2;
           }
       } 
    }
    for(int i=0;i<a.length;i++){
        if(a[i]>=x){
        System.out.println(s[i]+" "+a[i]);

    }
    }
}

}

my code is running fine but when submitting it is showing wrong answer???