# Swapping ints 2

**Computer Science**Level 2

In the permutation of \(a_{1}\cdots a_{n}\) of \(n\) distinct elements the list inversion are pair of elements \((a_{i},a_{j})\) such that \(i<j\) and \(a_{i} > a_{j}\). What is the worst-case running time if the inputs are restricted to permutations of \(1\cdots n\) with at most \(n\) inversions?