#include<bits/stdc++.h>
using namespace std;
int n, ans;
vector<int> a(1);
void dfs(int lst, int tot){
if(tot == 3){
++ans;
return;
}if(lst > n)
return;
for(int i = lst; i <= n; ++i){
if(a[i] > a[lst])
dfs(i, tot + 1);
}
}signed main(){
scanf("%d", &n);
for(int i = 1; i <= n; ++i){
int k;
scanf("%d", &k);
a.push_back(k);
}dfs(0, 0);
printf("%d", ans);
return 0;
}