Output not correct

when I tried the same thing for another test case, the program is not outputting the correct output. I have recheacked my code multiple time but I am certain its same.

The test case is
8
1 7 5 2 3 6 14 10
expected output
7
current output
6

My code is

'# include
'#include<ext/pb_ds/assoc_container.hpp>
'#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less,rb_tree_tag, tree_order_statistics_node_update> PBDS;

int main(){
#ifndef ONLINE_JUDGE
freopen(“input.txt”,“r”,stdin);
freopen(“output.txt”,“w”,stdout);
#endif

int n;
cin>>n;

int arr[n];

for(int i=0; i<n; i++){
    cin>>arr[n];
}

int inversion=0;
PBDS st;
for(int i=0;i<n;i++){
    inversion += st.size() - st.order_of_key(arr[i]);
    st.insert(arr[i]);
}

cout<<inversion;

}

i have attached ’ to not make the “#” a heading

Hey @Aug19CRXPP0079
Problem is here :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.