409007 - 超大值域逆序对

给定一个长度为 n 的序列 a1, a2, …, an,求该序列中的逆序对数量。

Input

第一行一个整数 n(1 ≤ n ≤ 10^5)。 第二行 n 个整数 ai(1 ≤ ai ≤ 10^9)。

Output

输出一个整数,表示逆序对总数。

Examples

Input

5
3 1 4 5 2

Output

4
Time Limit 1 second
Memory Limit 128 MB
Stats
上一题 下一题