#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)1e6 + 1;
pair<int, int> power[MAXN];
long long L[MAXN], R[MAXN], L_BIT[MAXN], R_BIT[MAXN];
int n;
bool comp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
void update(long long arr[], int pos, long long val) {
  for (; pos <= n; pos += (pos & -pos)) {
    arr[pos] += val;
  }
}
long long query(long long arr[], int pos) {
  long long sum = 0;
  for (; pos > 0; pos -= (pos & -pos)) {
    sum += arr[pos];
  }
  return sum;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> power[i].first;
    power[i].second = i;
  }
  sort(power, power + n);
  for (int i = 0; i < n; i++) {
    power[i].first = i + 1;
  }
  sort(power, power + n, comp);
  for (int i = 0; i < n; i++) {
    L[i] = query(L_BIT, n) - query(L_BIT, power[i].first);
    update(L_BIT, power[i].first, 1);
  }
  for (int i = n - 1; i >= 0; i--) {
    R[i] = query(R_BIT, power[i].first - 1);
    update(R_BIT, power[i].first, 1);
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += L[i] * R[i];
  }
  cout << ans;
  return 0;
}
