#include<cstdio>
#include<map>
#include<algorithm>
using namespace std;

struct BIT{
	int bit[200001];
	int size;
	BIT(int n){
		size = n;
		for(int i=0;i<=n;i++) bit[i] = 0;
	}
	void add(int i,int x){
		i++;
		while(i<=size){
			bit[i] += x;
			i += i & -i;
		}
	}
	int sum(int i){
		int ret = 0;
		i++;
		while(i>0){
			ret += bit[i];
			i -= i & -i;
		}
		return ret;
	}
};

int main(){
	int n,a[200000],b[200000],p[200000];
	long long ans = 0;
	map<int,int> mp;
	scanf("%d",&n);
	BIT bit(n);
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		b[i] = a[i];
	}
	sort(b,b+n);
	for(int i=0;i<n;i++) mp[b[i]] = i;
	for(int i=0;i<n;i++) p[mp[a[i]]] = i;
	for(int i=n-1;i>=0;i--){
		ans += bit.sum(p[i]);
		bit.add(p[i],1);
	}
	printf("%lld\n",ans);
}
#include <bits/stdc++.h>
#include <tuple>

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

const int INF = 1e9;

using namespace std;
long long int c = 0;


void merge(int a[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int l[n1+1], r[n2+1];
    REP(i, n1) l[i] = a[left + i];
    REP(i, n2) r[i] = a[mid + i];
    l[n1] = INF;
    r[n2] = INF;
    int i = 0;
    int j = 0;
    for(int k = left; k < right ; k++){
        if(l[i] <= r[j]){
            a[k] = l[i];
            i++;
        } else {
            c += n1-i;
            a[k] = r[j];
            j++;
        }
    }
    return;
}

void merge_sort(int a[], int left, int right){
    if (left+1 < right){
        int mid = (left + right) / 2;
        merge_sort(a, left, mid);
        merge_sort(a, mid, right);
        merge(a, left, mid, right);
    }
    return;
}

int main() {
    int n;
    cin >> n;
    int a[n];
    REP(i, n) cin >> a[i];
    merge_sort(a, 0, n);

    cout << c << endl;

    return 0;
}