#include using namespace std; typedef long long ll; typedef pair pii; typedef pair pll; #define ep emplace_back #define pb push_back #define mp make_pair #define rep(i,n) for(int i=0;i<(n);++i) constexpr int mod=1000000007; constexpr int mod1=998244353; vector dx={0,1,0,-1},dy={-1,0,1,0}; bool inside(int y,int x,int h,int w){ if(y=0 && x=0) return true; return false; } template inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; } template inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; } struct BIT{ vector a; int N; BIT(int n){ N = n; a.resize(n + 1); } void init(vector& a){ rep(i,N){ add(i + 1, a.at(i)); } } ll sum(int x){ ll ret = 0; while(x >= 1){ ret += a.at(x); x -= x & -x; } return ret; } void add(int x, int y){ while(y <= N){ a.at(y) += x; y += y & -y; } } }; ll calc(int n, vector a){ BIT b = BIT(n); ll ans = 0; rep(i,n){ ans += i - b.sum(a.at(i)); b.add(1, a.at(i)); } return ans; } int main(){ cin.tie(0); ios::sync_with_stdio(false); int n;cin >> n; vector a(n); rep(i,n) cin >> a.at(i); cout << calc(n,a) << endl; }