#include <bits/stdc++.h>
using namespace std;

class BIT
{
public:
    vector<int> bit;
    int M;

    BIT(int M):
        bit(vector<int>(M+1, 0)), M(M) {}

    int sum(int i) {
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, int x) {
        if (i > M) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};

int main()
{
	int n;
	cin >> n;
	vector<long long> A( n );
	vector<long long> B( n );
	for( int i = 0; i < n; i++ ) {
		cin >> A[i];
		B[i] = A[i];
	}

	sort( B.begin(), B.end() );
	map<long long, int> m;
	int v = 1;
	long long last = -1;
	for ( int i = 0; i < n; i++ ) {
		if( B[i] != last ) {
			last = B[i];
			m[ B[i] ] = v;
			v++;
		}
	}
	BIT bit( m.size() + 1 );
	long long ans = 0;
	for ( int i = 0; i < n; i++ ) {
		ans += i - bit.sum( m[ A[i] ] );
		bit.add( m[ A[i] ], 1 );
	}

	cout << ans << endl;
}

