#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int INF = 1e9;

ll ans = 0;

void merge(vector<int>& v, int left, int mid, int right)
{
  int n1 = mid - left, n2 = right - mid;
  vector<int> L(v.begin() + left, v.begin() + left + n1);
  vector<int> R(v.begin() + mid, v.begin() + mid + n2);
  L.push_back(INF);
  R.push_back(INF);
  for (int i = 0, j = 0, k = left; k < right; ++k) {
    if (L[i] <= R[j]) {
      v[k] = L[i];
      ++i;
    }
    else {
      v[k] = R[j];
      ++j;
      ans += n1 - i;
    }
  }
}

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

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<int> A(n);
  for (int i = 0; i < n; ++i) {
    fscanf(stdin, "%d", &A[i]);
  }
  mergeSort(A, 0, n);
  fprintf(stdout, "%lld\n", ans);
  return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)


template <typename T>
struct BIT{
    int n;
    vector<T> d;

    BIT(int sz){
        n = sz+10;
        d.resize(n);
    }

    void add(int i, T x){

        while(i<=n){
            d[i] += x;
            i += i&-i;
        }
    }

    T getSum(int i){
        T ret = 0;

        while(i>0){
            ret += d[i];
            i -= i&-i;
        }
        return ret;
    }
};


int main(){
    int n; cin >> n;
    int ma = 0;
    vector<int> a(n),sorted(n);
    rep(i,n){
        cin >> a[i];
        sorted[i] = a[i];
    }


    sort(sorted.begin(), sorted.end() );
    map<int,int> mp;
    rep(i,n){
        mp[sorted[i]] = i+1;
    }


    ll res = 0;
    BIT<int> bit(n);
    rep(i,n){
        res += i-bit.getSum(mp[a[i]]);
        bit.add(mp[a[i]],1);
    }

    cout << res << endl;
}
