import java.util.Scanner;

public class Hill {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long[] pole = new long[sc.nextInt()];
        for (int i = 0; i < pole.length; i++) {
            pole[i] = sc.nextLong();
        }

        long bridgeCount = 0;
        for (int i = 0; i < pole.length; i++) {
            long tempBridge = 0;
            for (int j = i + 1; j < pole.length; j++) {
                if (pole[i] > pole[j]) {
                    tempBridge++;
                } else if (pole[i] == pole[j]) {
                    bridgeCount += tempBridge;
                    break;
                } else if (pole[i] < pole[j]) {
                    break;
                }
            }
        }
        System.out.println(bridgeCount);
    }
}

