#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

struct BIT{
    int N;
    vector<int> dat;
    BIT() {}
    BIT(int n) {
        N = n;
        dat.resize(N + 1);
    }
    // update k th element (0-index)
    void add(int k, int x){
        k++;
        while(k <= N){
            dat[k] += x;
            k += k&-k;
        }
    }
    // sum [0, k) (0-index)
    int sum(int k){
        int s = 0;
        while(k > 0){
            s += dat[k];
            k -= k&-k;
        }
        return s;
    }
    // sum [a, b) (0-index)
    int query(int a, int b){
        return sum(b) - sum(a);
    }
};

int calc(int n, vector<int> &a){
    int res = 0;
    BIT bit(n);
    for(int j = 0; j < n; j++){
        int tmp = j - bit.sum(a[j]);
        res += tmp;
        bit.add(a[j], 1);
    }
    return res;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    int ans = calc(n, a);
    cout << ans << endl;
}