#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cassert>
#include<algorithm>
#include<functional>
#include<ctime>
using namespace std ;
ifstream fin("three.in") ;
ofstream fout("three.out") ;
/*O(n^3) Violence
int main()
{
int n , ans = 0 ; fin >> n ;
long long array[30001] ;
for ( int i = 1 ; i <= n ; i ++) fin >> array[ i ] ;
for ( int i = 1 ; i <= n ; i ++)
{
for ( int j = i+1 ; j <= n ; j ++)
{
for ( int h = j+1 ; h <= n ; h ++)
{
if( array[ i ] < array[ j ] && array[ j ] < array[ h ] ) ans ++ ;
}
}
}
fout << ans << endl ;
return 0 ;
}
*/
/**/
long long n , ans = 0 , array[31000][2] ;
int main()
{
fin >> n ;
memset ( array , 0 ,sizeof( array )) ;
for ( int i = 1 ; i <= n ; i ++ ) { fin >> array[ i ][0] ; array[ i ][1] = 1 ; }
array[ n ][1] = array[1][1] = 0 ;
for ( int i = n - 1 ; i > 1 ; i -- )
{
for ( int j = n ; j >= i + 1 ; j --)
{
if( array[ i ][0] < array[ j ][0] ) array[ i ][1] ++ ;
}
array[ i ][1] -- ;
}
/*
for ( int i = 1 ; i <= n ; i ++)
fout << array[ i ][0] << " " << array[ i ][1] << " " << endl ;
*/
for ( int i = 1 ; i <= n ; i ++)
{
for ( int j = i + 1 ; j <= n ; j ++)
if ( array[ i ][0] < array[ j ][0] ) ans += array[ j ][1] ;
}
fout << ans << endl ;
return 0 ;
}