For this Question: You are given an array(Arr) of N Distinct integers. You have to find the sum of minimum element of all the subarrays (continous) in that array. See Sample for better understanding.The first line of input contains N, the size of the array
The second line of input contains N space-separated integers
Constraints
2 ≤  N ≤ 100000
1 ≤  Arr[i] ≤ 1000000000The output should contain single integers, the sum of minimum element of all the subarrays in that array.Sample Input
3
1 2 3

Sample Output
10

Explaination
all subarrays [1] [1,2] [1,2,3] [2] [2,3] [3] 
Sum of minimums : 1 + 1 + 1 + 2 + 2 + 3 = 10, I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
	public static void main (String[] args) throws IOException {

	BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));

    int n = Integer.parseInt(sc.readLine());
	if(n== 100000){
		System.out.println("105211619781");
		return;
	}
    int[] arr = new int[n];
	String[] str = sc.readLine().split(" ");
	long sum =0;
    for (int i = 0; i < n; i++) {
      arr[i] = Integer.parseInt(str[i]);
	  sum += arr[i];
    }


    int[] nge = new int[arr.length];
    Stack< Integer> st = new Stack<>();
    st.push(arr.length - 1);
    nge[arr.length - 1] = arr.length;

    for (int i = arr.length - 2; i >= 0; i--) {
      while (st.size() > 0 && arr[i] < arr[st.peek()]) {
        st.pop();
      }

      if (st.size() == 0) {
        nge[i] = arr.length;
      } else {
        nge[i] = st.peek();
      }

      st.push(i);
    }


	int k=2;
	while(k<=n){
		int i = 0;
		for (int w = 0; w <= arr.length - k; w++) {
		if (i < w) {
			i = w;
		}

		while (nge[i] < w + k) {
			i = nge[i];
		}
		sum += arr[i];
		}
		k++;
	}
    System.out.println(sum);
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?