Please tell the mistake,it is working fine on ellipse but not on coding blocks IDE

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scn=new Scanner(System.in);
int n=scn.nextInt();
int arr[]=new int [n];
for(int i=0;i<n;i++) {
arr[i]=scn.nextInt();
}
sort(arr);
display(arr);
}

public static void sort(int []arr) {
for(int counter=0;counter<=arr.length-1;counter++) {
int val=arr[counter];
int j=counter-1;
while(j>=0 && arr[j]>val)
{
arr[j+1]=arr[j];
jā€“;
}
arr[j+1]=val;
}
}
public static void display(int []arr) {
for(int i=0;i<arr.length;i++) {
System.out.println(arr[i]);
}
}
}