Works fine in intellij an iam getting the answer correct but last condition is not satisfied.Please help.
public class Solution {
    private static Scanner scanner = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int N = scanner.nextInt();
        int temp;
        int[] array = new int[N];
        for (int i = 0; i < N; i++){
            array[i] = scanner.nextInt();
        }

        for (int i = 0; i < N; i++){
            for (int j = i+1; j < N; j++){
                if (array[i] < array[j]){
                    temp = array[i];
                    array[i] = array[j];
                    array[j] = temp;
                }
            }
        }
        int maximum = array[0];
        System.out.println(maximum);
    }
}