1093 求逆序数对


Submit solution

Points: 100
Time limit: 1.0s
Memory limit: 32M

Problem types
Allowed languages
C, C++, Java, Python

Description

逆序数定义如下:在序列S中,若iA[j],则称A[i]与A[j]为S中的一对逆序数。

Input

第一行给定整数N(2≤N≤50),下一行N个整数(没有重复,N=0时为输入结束)。

Output

输出每组序列的逆序数对。

Sample

Input

3
1 2 3
3
3 2 1
3
1 3 2
0

Output

0
3
1

Comments

There are no comments at the moment.