Problem1541--逆序对

1541: 逆序对

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MiB

Description

    对于给定的一段正整数序列,逆序对就是序列中ai>aj且i<j的有序对。计算出给定的一段正整数序列中逆序对的数目。

Input

第一行,一个数n,表示序列中有n个数。
第二行n个数,表示给定的序列。序列中每个数字不超过10^9。

Output

给定序列中逆序对的数目。

Sample Input Copy

6
5 4 2 6 3 1

Sample Output Copy

11

HINT

对于25%的数据,n≤2500

对于50%的数据,n≤4×10^4

对于100%的数据,n≤5×10^5

Source/Category

排序