#include<bits/stdc++.h>

template<class RandomAccessIterator>
void merge_sort(RandomAccessIterator first, RandomAccessIterator last, size_t& ans){
    auto n = last - first;
    if(n <= 1)return;
    merge_sort(first, first + n / 2, ans);
    merge_sort(first + n / 2, last, ans);
    auto f = first, m1 = first + n / 2, m2 = first + n / 2, l = last;
    while(m1 != f){
        while(m2 != l && *f > *m2)++m2;
        ans += m2 - m1;
        ++f;
    }
    std::inplace_merge(first, first + n / 2, last);
}

int main(){
    using namespace std;
    size_t n;
    cin >> n;
    vector<size_t> a(n);
    for(auto& i : a)cin >> i;
    size_t ans{0};
    merge_sort(a.begin(), a.end(), ans);
    cout << ans << endl;
}
