#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

using i64=long long;

template <typename T>
struct BinaryIndexedTree {
    size_t n;
    vector<T> tree;
    BinaryIndexedTree(size_t n, T e=0): n(n) {
        tree = vector<T>(n+1, e);
    }
    void add(size_t i, T w) {
        // v[i] += w;
        // i in [1, n]
        for (size_t j=i; j<=n; j+=j&-j)
            tree[j] += w;
    }
    T sum(T m) {
        // returns sum of v[i] for i in [1, m]
        T sum_=0;
        for (size_t i=m; i>0; i-=i&-i)
            sum_ += tree[i];

        return sum_;
    }
};

int main() {
    size_t n;
    scanf("%zu", &n);

    vector<int> a(n);
    for (size_t i=0; i<n; ++i)
        scanf("%d", &a[i]);

    map<int, size_t> m;
    for (size_t i=0; i<n; ++i)
        m[a[i]] = i;

    vector<int> b(n);
    int rank_=1;
    for (pair<const int, size_t> p: m)
        b[p.second] = rank_++;

    BinaryIndexedTree<i64> tree(n+1);
    i64 res=0;
    for (size_t i=0; i<n; ++i) {
        res += i-tree.sum(b[i]);
        tree.add(b[i], 1);
    }

    printf("%lld\n", res);
    return 0;
}
#include <iostream>
#include <vector>

#define SENTINEL 1000000001

using namespace std;

long long cnt = 0;

void merge(vector<int> &A, int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> L(n1 + 1), R(n2 + 1);
	for (int i = 0; i < n1; i++)
	{
		L[i] = A[left + i];
	}
	for (int i = 0; i < n2; i++)
	{
		R[i] = A[mid + i];
	}
	L[n1] = SENTINEL;
	R[n2] = SENTINEL;
	int i = 0;
	int j = 0;
	for (int k = left; k < right; k++)
	{
		if (L[i] <= R[j])
		{
			A[k] = L[i];
			i++;
		}
		else
		{
			A[k] = R[j];
			cnt += n1 - i; // L[]は昇順に整列されているので、i番目以降のL[]の要素(n1 - i)個はすべてR[j]より大きくなる
			j++;
		}
	}
}

void mergeSort(vector<int> &A, int left, int right)
{
	if (left + 1 < right)
	{
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main() {
	int n;
	cin >> n;
	vector<int> S(n);
	for (int i = 0; i < n; i++)
	{
		cin >> S[i];
	}
	mergeSort(S, 0, n);

	cout << cnt << endl;
	return 0;
}
