// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

using ll = long long;



int main() {

    int M = 1 << 18 + 1;

    int N;

    cin >> N;

    vector<int> A(N), a(N), ord(N);

    for ( int i = 0; i < N; i++ ) {

        cin >> A[i];

        a[i] = A[i];

    }



    sort(a.begin(), a.end());

    for ( int i = 0; i < N; i++ ) {

        ord[i] = lower_bound(a.begin(), a.end(), A[i]) - a.begin();

    }



    ll ans = 0;

    vector<int> bit(M);

    int k,sum;

    for ( int i = 0; i < N; i++ ) {

        // add

        k = ord[i] + 1;

        while ( k <= M ) {

            bit[k]++;

            k += k & -k;

        }

        // sum

        sum = 0;

        k = ord[i] + 1;

        while ( k > 0 ) {

            sum += bit[k];

            k -= k & -k;

        }

        

        ans += i + 1 - sum;

    }



    cout << ans << '\n';

    return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

using ll = long long;



template<typename T> struct BIT {

    int max_n;

    vector<T> data;

    const bool zi;

    const T unit;

    BIT<T>(int n, bool zi = true, T u = T(0)) : max_n(n), zi(zi), unit(u) {

        data.assign(max_n + 1, u);

    }

    void add(int i, T x) {

        if ( zi ) i++;

        assert( i > 0 );

        while ( i <= max_n ) {

            data[i] += x;

            i += i & -i;

        }

    }

    T sum(int i) {

        if ( zi ) i++;

        assert( i > 0 );

        T s = unit;

        while ( i > 0 ) {

            s += data[i];

            i -= i & -i;

        }

        return s;

    }

    vector<T> get_sum_list(int l, int r) {

        vector<T> ret;

        for ( int i = l; i <= r; i++ ) {

            ret.push_back(sum(i));

        }

        return ret;

    }

};



ll solve() {

    ll N;

    cin >> N;

    vector<ll> A(N);

    for ( int i = 0; i < N; i++ ) {

        cin >> A[i];

    }



    vector<ll> xs1(A);

    sort(xs1.begin(), xs1.end());

    xs1.erase(unique(xs1.begin(), xs1.end()), xs1.end());

    for ( int ii = 0; ii < A.size(); ii++ ) {

        A[ii] = lower_bound(xs1.begin(), xs1.end(), A[ii]) - xs1.begin();

    }

    

    BIT<ll> bit(N+1);

    ll ans = 0;

    for ( int i = 0; i < N; i++ ) {

        ans += i - bit.sum(A[i]);

        bit.add(A[i], 1);

    }



    return ans;

}



int main() {

    auto ans = solve();

    cout << ans << "\n";

    return 0;

}


// Fastest known solution for this problem:
#include<stdio.h>



#define MAX 200000

#define SENTINEL 1200000000



typedef long long hyper;

hyper cnt = 0;



void Merge(int* A, int left, int mid, int right)

{

    int L[MAX], R[MAX];

    int i, j, k, n1, n2;

    n1 = mid - left;

    n2 = right - mid;

    for(i = 0; i < n1; i++) L[i] = A[i + left];

    for(j = 0; j < n2; j++) R[j] = A[j + mid];



    L[n1] = SENTINEL;

    R[n2] = SENTINEL;

    i = j = 0;



    // sorting.

    for(k = left; k < right; k++){



        if(L[i] <= R[j]){ A[k] = L[i]; i++; }



        else{ A[k] = R[j]; j++; cnt = cnt + n1 - i; } // add n1 - i.

    }

}



void MergeSort(int* A, int left, int right)

{

    int mid;

    if(left + 1 < right){

        mid = (left + right) / 2;

        MergeSort(A, left, mid);

        MergeSort(A, mid, right);

        Merge(A, left, mid, right);

    }

}



int main()

{

    int i, n, A[MAX];

    scanf("%d", &n);

    for(i = 0; i < n; i++) scanf("%d", &A[i]);



    MergeSort(A, 0, n);

    printf("%lld\n", cnt);



    return 0;

}