For this Question: You are given an array P of size N. You have to find the maximum value of <b>P<sub>i</sub> % P<sub>j</sub></b> for all possible i, j pairs.First line contains a single integer N.
The second line of the input contains N space seperated integers.

Constraints:
2 <= N <= 10<sup>5</sup>
1 <= P<sub>i</sub> <= 10<sup>9</sup>Print the maximum value of P<sub>i</sub> % P<sub>j</sub> for all possible i, j pairs in the array.Sample Input:
5
8 6 7 9 4

Sample Output:
8

Explanation:
i = 1, j = 4 (1-based indexing) will give the maximum possible result over all (i, j) pairs., I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {


    static int getMaxValue(int arr[], int arr_size)
    {
        int i, first, second;


        if (arr_size < 2)
        {
            return 0;
        }



        first = second = Integer.MIN_VALUE;
        for (i = 0; i < arr_size; i++)
        {



            if (arr[i] > first)
            {
                second = first;
                first = arr[i];
            }



            else if (arr[i] > second && arr[i] != first)
            {
                second = arr[i];
            }
        }


        if (second == Integer.MIN_VALUE)
        {
            return 0;
        }
        else
        {
            return second;
        }
    }
	public static void main (String[] args) throws IOException {

	   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	   int n = Integer.parseInt(br.readLine());
	   String[] num = br.readLine().split(" ");

		int arr[] = new int[n];
		for(int i=0;i<n;i++) arr[i] =Integer.parseInt(num[i]);
		int max = Integer.MIN_VALUE;





		System.out.println(getMaxValue(arr, n));

	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?