逆序数=∑i=1n−1∑j=i+1n[σi>σj] \text{逆序数} = \sum_{i=1}^{n-1} \sum_{j=i+1}^{n} [\sigma_i > \sigma_j] 逆序数=i=1∑n−1j=i+1∑n[σi>σj]