#include using namespace std; int main() { int N; cin >> N; vectorA(N); vectorB; for(int i = 0; i < N; i++) { cin >> A[i]; if(i) { if(A[i-1] < A[i]) { B.push_back(0); } else { B.push_back(1); } } } long long ans = 0,cnt = 0; for(int i = 0; i < N-1; i++) { if(B[i] == 1) { ans += i-cnt; cnt++; } } cout << ans << endl; }