import std.array, std.stdio, std.conv, std.string, std.math, std.random, std.range,std.functional;
import std.algorithm.searching, std.algorithm.sorting, std.algorithm.iteration, std.algorithm.comparison;
 
long count;
 
void main()
{
    readln();
    int[] list = readln().split.to!(int[]);
    mergeSort(list);
    writeln(count);
}
 
int[] merge(int[] a, int[] b)
{
    int[] res;
    res.reserve(a.length+b.length);
    while(a.length != 0 && b.length != 0)
    {
        if(a.front < b.front)
        {
            res ~= a.front;
            a.popFront();
        }else{
            count+=a.length;
            res ~= b.front;
            b.popFront();
        }
    }
    res ~= a ~ b;
    return res;
}
 
int[] mergeSort(int[] list)
{
    if(list.length == 0)
        return list;
    if(list.length == 1)
        return list;
    auto mid = list.length / 2;
    auto a = mergeSort(list[0..mid]);
    auto b = mergeSort(list[mid..$]);
    return merge(a, b);
}
 
sizediff_t minIndex(alias pred="a<b", R) (R list)
    if(isForwardRange!R && !isInfinite!R && is(typeof(binaryFun!pred(list.front, list.front))))
{
    assert(!list.empty);
    typeof(list.front) min = list.front;
    sizediff_t minPos;
    sizediff_t curPos;
    for(list.popFront(); !list.empty; list.popFront())
    {
        curPos++;
 
        if(binaryFun!pred(list.front, min))
        {
            min = list.front;
            minPos = curPos;
        }
    }
    return minPos;
}
