#include<bits/stdc++.h>
#define ull unsigned long long
using namespace std;
int n,a[80002];
ull ans=0;
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int i=1;i<n;i++){
int sum=a[i];
for(int j=i+1;j<=n;j++){
if(sum<=a[j]) break;
else ans++;
}
}
cout<<ans;
return 0;
}