I m getting the wrong output

I guess i tried coding everything correct , but it somehow shows wrong answer. I am not able to find my mistake . could you please help?

@vijit.chandhok99 hey vijit share your implementation through cb.lk/ide

@vijit.chandhok99 hey vijit I am extremely sorry for the late response this is because when you post a reply without tagging me without @ symbol followed by my name It will never give me notification so please always follow this process to post your doubts now comes to the point.
In your code there is two mistakes
1 ans+=( ( j - i ) * ( j - i + 1 ) ) / 2 ;
It should be like this.
ans+ = ( ( j - i ) * ( j - i + 1 ) ) / 2 ;
2 h.insert(make_pair( j , arr[j] ) );
It should be like this
h.insert(make_pair( arr[j] , arr[j]) );

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.