#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") ;
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 ;
}