#include #include using namespace std; using namespace atcoder; #define ll long long void solve() { int n; cin >> n; vector a(n); for(int i=0; i> a[i]; int r = 0; ll answer = 0; for (int i=1; i a[i-1]) r++; else answer += (ll)r; } cout << answer << "\n"; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int t = 1; // std::cin >> t; while (t--) solve(); return 0; }