#include <climits>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>


typedef std::vector<int> TList;
long long int c;
void merge(TList& A, int left, int mid, int right)
{
  int n1 = mid - left;
  int n2 = right - mid;
  TList L(A.begin() + left, A.begin() + left + n1);
  L.push_back(INT_MAX);

  TList R(n2+1);
  for(int i = 0; i < n2; ++i){
    R[i] = A[mid + i];
  }
  R[n2] = INT_MAX;
  
  int i = 0;
  int j = 0;
  for(int k = left; k < right; ++k){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else{ 
      A[k] = R[j];
      j = j + 1;
      c += L.size() - 1 - i;
    }
  }
}

void mergeSort(TList& A, int left, int right)
{
  if(left+1 < right){
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);   
    merge(A, left, mid, right);
  }
}

int main()
{
    int n;
    std::cin >> n;
    TList A(n);
    for(std::size_t i = 0; i < n; ++i){
        std::cin >> A[i];
    }
    c = 0;
    mergeSort(A, 0, n);
    std::cout << c << std::endl;
}
#include <bits/stdc++.h>
using namespace std;

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r) - sum(l-1);
  }
};

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  
  auto b=a;
  vsort(b);
  b.erase(unique(all(b)),b.end());
  // rep(i,b.size()) cout<<b[i]<<' ';
  // cout<<endl;
  BIT<ll> bit(b.size()+5);
  
  ll ans=0;
  rep(i,n){
    ll rank=lower_bound(all(b),a[i])-b.begin()+1;
    // cout<<rank<<endl;
    ans+=i-bit.sum(rank);
    bit.add(rank);
  }
  
  cout<<ans<<endl;
  
  
}
