@count_num_inversion = 0

def merge(left, mid, right)
    leftArr = @array[left..mid]
    rightArr = @array[mid+1..right]
    leftArr.push(1000000001) #??¶?´??????§????????§???
    rightArr.push(1000000001)
    l = 0
    r = 0
    (left..right).each do |i|
        if leftArr[l] <= rightArr[r]
            @array[i] = leftArr[l]
            l += 1
        else
            @array[i] = rightArr[r]
            r += 1
            @count_num_inversion += (mid - left) - l + 1 
        end
    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.chomp.to_i
@array = gets.chomp.split.map(&:to_i)
mergeSort(0,n-1)
puts @count_num_inversion