#include <bits/stdc++.h>

#define ll long long
#define el '\n'
#define TASK "test"
#define fi first
#define se second

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(s) (int)(s).size()

#define FOR(i, a, b, s) for (auto i = (a), _b = (b); i <= _b; i += (s))
#define FORD(i, a, b, s) for (auto i = (a), _b = (b); i >= _b; i -= (s))
#define REP(i, n) for (int i = 1, _n = (n); i <= _n; ++i)
#define FORE(i, v) for (auto &i : (v))

#define ShinzouWoSasageyo ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FoundingTitan if (fopen(TASK ".inp", "r")) freopen(TASK ".inp", "r", stdin), freopen(TASK ".out", "w", stdout);

using namespace std;

template<class X, class Y>
bool minimize(X &x, const Y &y)
{
    if (x > y)
    {
        x = y;
        return true;
    }
    return false;
}

template<class X, class Y>
bool maximize(X &x, const Y &y)
{
    if (x < y)
    {
        x = y;
        return true;
    }
    return false;
}

const int N      = 6e4 + 9;
const int INT_MX = (1LL << 30);
const ll LL_MX   = (1LL << 62);
const int mod    = 1e9 + 7;
const int base   = 131;

/*
     Author: Minh Son Nguyen - Huynh Dong Nhi Nguyen - Tanh Linh High School
     A2 - K39 (2025 - 2028)
*/

int n;
vector<int> a;
int ans = 0;

vector<int> Merge(const vector<int> &a, const vector<int> &b)
{
    vector<int> c;
    int i = 0, j = 0;
    while (i < sz(a) || j < sz(b))
    {
        if (i == sz(a))
        {
            c.push_back(b[j++]);
        }
        else if (j == sz(b))
        {
            c.push_back(a[i++]);
        }
        else if (a[i] <= b[j])
        {
            c.push_back(a[i++]);
        }
        else
        {
            ans += sz(a) - i;
            c.push_back(b[j++]);
        }
    }
    return c;
}

void Msort(vector<int> &a, int l, int r)
{
    if (l == r) return;

    int mid = (l + r) >> 1;
    Msort(a, l, mid);
    Msort(a, mid + 1, r);

    vector<int> b, c;
    FOR (i, l, mid, 1) 
    {
        b.push_back(a[i]);
    }
    FOR (i, mid + 1, r, 1)
    {
        c.push_back(a[i]);
    }

    b = Merge(b, c);
    FOR (i, l, r, 1)
    {
        a[i] = b[i - l];
    }

}

namespace ErenxMikasa
{
    /*
         Welcome to the battlefield :D
         Now, let's solve the problem!
    */

    void process(void)
    {
        cin >> n;
        a.resize(n + 9);
        FOR (i, 1, n, 1)
        {
            cin >> a[i];
        }

        Msort(a, 1, n);
        cout << ans;

    }
}

signed main(void)
{
    ShinzouWoSasageyo;
    FoundingTitan;
    ErenxMikasa::process();
    return 0;
}

/*
    That is the end of my template, let's drink a coffee and chill with my code ~~
    Dedicate your heart! ~~~ Shinzou Wo Sasageyo! - Scout Regiment
    Tatakae! ~~~ Keep fighting - Eren Yeager
*/