import java.util.*;
import java.io.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[]nums = new int[n];
		for(int i=0;i<n;i++){
		    nums[i]=sc.nextInt();
		}
		
		int[] pref = new int[n];
		pref[0]=0;
		int[] suff = new int[n];
		suff[n-1]=0;
		
		int j=1;
		while(j<=n-1){
		    int i=0;
		    int count=0;
		    while(i<j){
		        if(nums[i]>nums[j]){
		            count++;
		        }
		        i++;
		    }
		    pref[j]=count;
		    j++;
		}
		
		j=n-2;
		while(j>=0){
		    int k=n-1;
		    int count=0;
		    while(j<k){
		        if(nums[j]<nums[k]){
		            count++;
		        }
		        k--;
		    }
		    suff[j]=count;
		    j--;
		}
		int count_triplets=0;
		for(int x=0;x<n;x++){
		    count_triplets+=pref[x]*suff[x];
		}
		
		System.out.print("No of triplets in the array " +count_triplets);
	}
}