#include using namespace std; #define rep(i,n) for(int i = 0; i < int(n); i++) #define per(i,n) for(int i = (n) - 1; 0 <= i; i--) #define rep2(i,l,r) for(int i = (l); i < int(r); i++) #define per2(i,l,r) for(int i = (r) - 1; int(l) <= i; i--) #define MM << " " << #define pb push_back #define eb emplace_back #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) #define sz(x) (int)x.size() template void print(const vector &v, T x = 0) { int n = v.size(); for (int i = 0; i < n; i++) cout << v[i] + x << (i == n - 1 ? '\n' : ' '); if (v.empty()) cout << '\n'; } using ll = long long; using pii = pair; using pll = pair; template bool chmax(T &x, const T &y) { return (x < y) ? (x = y, true) : false; } template bool chmin(T &x, const T &y) { return (x > y) ? (x = y, true) : false; } // const ll MOD = 1'000'000'007; const ll MOD = 998'244'353; /////////////////////////////////////////////////////////////// template using minheap = priority_queue, greater>; template using maxheap = priority_queue; template int lb(const vector &v, T x) { return lower_bound(begin(v), end(v), x) - begin(v); } template int ub(const vector &v, T x) { return upper_bound(begin(v), end(v), x) - begin(v); } template void rearrange(vector &v) { sort(begin(v), end(v)); v.erase(unique(begin(v), end(v)), end(v)); } using namespace std; int main() { int n; cin >> n; vector da(n); rep(i,n) cin >> da[i]; ll ans = 0; int c = 0; rep(i,n-1) { if(da[i+1] > da[i]) { c++; } else { ans += c; } } cout << ans << endl; }