$invNum =0
def merge(left, mid, right)
    leftArr = $arr[left..mid]
    rightArr = $arr[mid+1..right]
    leftArr << 1000000001
    rightArr << 1000000001
    l = r = 0
    (left..right).each {|i|
        if leftArr[l] <= rightArr[r]
            $arr[i] = leftArr[l]
            l += 1
        else
            $arr[i] = rightArr[r]
            r += 1
            $invNum += mid - left - l + 1
        end
    }
end

def mergeSort(left, right)
    mid = (left + right)/2
    if left + 1 < right
        mergeSort(left, mid)
        mergeSort(mid+1, right)
        merge(left, mid, right)
    elsif left + 1 == right
        merge(left, mid, right)
    end
end

N = gets.to_i
$arr = gets.split.map &:to_i
mergeSort(0,N-1)
puts $invNum