#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
int num[30010],f[2][30010];
unsigned long long total;
int main(void)
{
freopen("three.in","r",stdin);
freopen("three.out","w",stdout);
int i,j,n;
scanf("%d",&n);
for (i=1;i<=n;i++)
scanf("%d",&num[i]);
for (i=1;i<=n;i++)
{
for (j=i-1;j>=1;j--)
if (num[j]<num[i])
{
f[0][i]++;
f[1][i]+=f[0][j];
}
total+=f[1][i];
}
cout<<total<<endl;
return(0);
}