Rational Bubble Sort

From Codeforces. Geometry. Solve the geometry problem "Rational Bubble Sort".

Examples
Input: [1,2,3]
Output: 0
Hints

Rational Bubble Sort

**From Codeforces.** Geometry. Solve the geometry problem "Rational Bubble Sort".