#include #include using namespace std; using ll = long long; int guchoku(int n, const vector &a){ vector b(n-1); for(int i = 0; i < n; i++) b[i] = a[i] < a[i+1]; vector Q; for(int i = 0; i < n-2; i++){ if(b[i] && !b[i+1]) Q.emplace_back(i); } int ans = 0; while(!Q.empty()){ int c = Q.back(); Q.pop_back(); ans++; b[c] = false; b[c+1] = true; if(c-1 >= 0 && b[c-1] && !b[c]) Q.emplace_back(c-1); if(c+2 < n-1 && b[c+1] && !b[c+2]) Q.emplace_back(c+1); } return ans; } ll solve(int n, const vector &a){ vector b(n-1); for(int i = 0; i < n; i++) b[i] = a[i] < a[i+1]; int cnt = 0; ll ans = 0; for(int i = b.size()-1; i >= 0; i--){ if(b[i]){ cnt++; ans += b.size()-i-cnt; } } return ans; } int main(){ int n; cin >> n; vector a(n); for(auto &it: a) cin >> it; cout << solve(n, a) << endl; return 0; }