#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define endl "\n"
#define ll long long
#define pb emplace_back
#define fi first
#define se second
#define pll pair<ll, ll>
#define ull unsigned long long
#define ld long double

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=n-1; i>=0; i--)
#define repa(i,a,b) for(ll i=(a);i<=(b);i++)
#define all(x) (x).begin(), (x).end()
#define ordered_set tree<int , null_type, less<int> , rb_tree_tag, tree_order_statistics_node_update>
/*
 Ordered set docs:
 order_of_key (k) : Number of items strictly smaller than k .
 find_by_order(k) : K-th element in a set (counting from zero).
*/
#define blc boost::lexical_cast<long long>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
const int MOD = 1e9+7;

ll add(ll x, ll y) {ll res=x+y; return(res>=MOD?res-MOD:res);}

ll sub(ll x, ll y) {ll res=x-y; return(res<0?res+MOD:res);}

ll lcm(ll x, ll y) {ll res=(x*y)/__gcd(x,y); return res;}

ll powerLL(ll x, ll n, ll mod) 
{ 
    ll result = 1; 
    while (n) { if (n & 1) result = (result%mod * x%mod) % mod; n = n / 2; x = (x%mod * x%mod) % mod; } return result; 
} 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int getSum(int BITree[], int index) 
{ 
    int sum = 0; // Initialize result 
  
    // Traverse ancestors of BITree[index] 
    while (index > 0) { 
        // Add current element of BITree to sum 
        sum += BITree[index]; 
  
        // Move index to parent node in getSum View 
        index -= index & (-index); 
    } 
    return sum; 
} 
  
// Updates a node in Binary Index Tree (BITree) at given index 
// in BITree. The given value 'val' is added to BITree[i] and 
// all of its ancestors in tree. 
void updateBIT(int BITree[], int n, int index, int val) 
{ 
    // Traverse all ancestors and add 'val' 
    while (index <= n) { 
  
        // Add 'val' to current node of BI Tree 
        BITree[index] += val; 
  
        // Update index to that of parent in update View 
        index += index & (-index); 
    } 
} 
  
// Converts an array to an array with values from 1 to n 
// and relative order of smaller and greater elements remains 
// same. For example, {7, -90, 100, 1} is converted to 
// {3, 1, 4, 2 } 
void convert(vector<ll> &arr, int n) 
{ 
    // Create a copy of arrp[] in temp and sort the temp array 
    // in increasing order 
    int temp[n]; 
    for (int i = 0; i < n; i++) 
        temp[i] = arr[i]; 
    sort(temp, temp + n); 
  
    // Traverse all array elements 
    for (int i = 0; i < n; i++) { 
        // lower_bound() Returns pointer to the first element 
        // greater than or equal to arr[i] 
        arr[i] = lower_bound(temp, temp + n, arr[i]) - temp + 1; 
    } 
} 
  
// Function to find smaller_right array 
ll findElements(vector<ll> &arr, int n) 
{ 
    convert(arr, n); 
	int BIT[n + 1]; 
    for (int i = 1; i <= n; i++) 
        BIT[i] = 0; 
	int greater_left[n]; 
	ll res = 0;
	for (int i = 0; i < n; i++) { 
		res += i - getSum(BIT, arr[i]); 
		updateBIT(BIT, n, arr[i], 1); 
    } 
  
    return res;
    cout << "Greater left: "; 
  
    // Print greater_left array 
    for (int i = 0; i < n; i++) 
        cout << greater_left[i] << " "; 
} 
void solve()
{
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n)
    	cin>>a[i];
	ll res = findElements(a,n);
	cout<<res<<endl;
}
int32_t main()
{
    fast;
    int t;
    t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0; 
}