#include #define rep(i,n) for (int i = 0; i < (n); i ++) using namespace std; typedef long long ll; typedef pair PL; typedef pair P; const ll INF = 1e9; const ll MOD = 1e9 + 7; template class BinaryIndexedTree { int N; vector bit; public : BinaryIndexedTree(int _N): N(_N){ bit = vector(N + 1,0); } void add(int i,int x) { while (i <= N) { bit[i] += x; i += (i & -i); } } T sum(int i) { T ret = 0; while (i > 0) { ret += bit[i]; i -= (i & -i); } return ret; } }; int main() { int N; cin >> N; vector M(N); rep(i,N) cin >> M[i]; int ans = 0; BinaryIndexedTree bit(N); rep(i,N) { ans += i - bit.sum(M[i]); bit.add(M[i],1); } cout << ans << endl; }