Inverse Pair
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

For a sequence , we define the weight of it is the number of pairs satisfy and .

Now give you a permutation , you need to choose a sequence satisfies to minimize the weight of sequence which satisfies .

输入描述:

The first line has one integer .

The second line has integers .

It's guaranteed that a_i is a permutation of


输出描述:

Output the minimum weight of  you can get.
示例1

输入

复制
5
4 3 2 5 1

输出

复制
5