using System;
using System.Linq;

class Solution {
    public static void insertionSort (int[] A) {
        int swapNumber = 0;
        var j = 0;
        for (var i = 1; i < A.Length; i++) {
            var value = A[i];
            j = i - 1;
            while (j >= 0 && value < A[j]) {
                A[j + 1] = A[j];
                swapNumber++;
                j = j - 1;
            }
            A[j + 1] = value;
        }
        Console.WriteLine(Convert.ToString(swapNumber));
    }

    static void Main(string[] args) {
        Console.ReadLine();
        int [] _ar = (from s in Console.ReadLine().Split() select Convert.ToInt32(s)).ToArray();
        insertionSort(_ar);
    }
}
