#include <bits/stdc++.h>
using namespace std;
const int maxn = 3 * 1e6;
int n, ft[2][maxn], id, A[maxn], F[2][maxn];
set<pair<int, int> > S;
void update(int k, int i) {
  for (; k < n; k += (k & (-k))) ft[i][k]++;
}
int query(int a, int i) {
  int res = 0;
  for (; a; a -= (a & -a)) res += ft[i][a];
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> A[i], S.emplace(A[i], i);
  for (auto p : S) A[p.second] = ++id;
  for (int k = 0; k < 2; ++k) {
    reverse(A, A + n);
    for (int i = 0; i < n; ++i) {
      F[k][i] = query(A[i], k);
      update(A[i], k);
      A[i] = n - A[i] + 1;
    }
  }
  long long res = 0;
  for (int i = 0; i < n; ++i) res += F[0][i] * 1LL * F[1][n - i - 1];
  cout << res << '\n';
}
