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: 
#include <bits/stdc++.h>

using namespace std;



long long sumSubarrayMins(long long A[], long n)
{

    long long left[n], right[n];



    stack<pair<long long , long long> > s1, s2;



    for (int i = 0; i < n; ++i) {

        int cnt = 1;



        while (!s1.empty() && (s1.top().first) > A[i]) {

            cnt += s1.top().second;

            s1.pop();

        }



        s1.push({ A[i], cnt });

        left[i] = cnt;

    }



    // getting number of element larger than A[i] on Right.

    for (int i = n - 1; i >= 0; --i) {

        long long cnt = 1;



        // get elements from stack until element greater

        // or equal to A[i] found

        while (!s2.empty() && (s2.top().first) >= A[i]) {

            cnt += s2.top().second;

            s2.pop();

        }



        s2.push({ A[i], cnt });

        right[i] = cnt;

    }



    long long result = 0;



    for (int i = 0; i < n; ++i)

        result = (result + A[i] * left[i] * right[i]);



    return result;
}


int main()
{
int n;
cin>>n;
long long a[n];
for(int i=0;i<n;i++){
    cin>>a[i];
}
    cout << sumSubarrayMins(a, n);



    return 0;
}
, In this Programming Language: C++, Now tell me if this Code is compilable or not?