Aggresive Cow wrong approach

import java.util.*;

public class Main {

public static void main(String args[]) {
	Scanner scn = new Scanner (System.in);
	int n = scn.nextInt();

	int a = scn.nextInt();
	int [] arr = new int[n];
	for(int i=0;i<n;i++){
      arr[i]=scn.nextInt();
	}
	bubblesort(arr);
	int [] arr1 = new int [n];
	int sum=0;
	for(int i=0;i<n;i++){
       sum=arr[i]-arr[0];
	   arr1[i]=sum;
	}
	int max =arr1[0];
	for(int j=0;j<n;j++){
		if(arr1[j]>max && arr1[j]*a<=arr[n-1])
		    max=arr1[j];
	}
	System.out.println(max);

}

public static void bubblesort(int [] arr ){

for(int i=0;i<arr.length-1;i++){
	for(int j=0;j<arr.length-1-i;j++){
		if(arr[j]>arr[j+1]){
			int temp = arr[j];
			arr[j]=arr[j+1];
			arr[j+1]=temp;
		}
	}
}

}

}

This code is solving 2 test cases but for rest of the test it is showing wrong ans ,So please Help Me

Hey @uttkarsh17goswami
Try for this input :
7
2 4 6 7 3 5 1
2
you are doing wrong

what should be the correct output for the input you have mentioned

@uttkarsh17goswami
6