#include <bits/stdc++.h>
using namespace std;
long long int tree_big[4 * 1000010];
long long int tree_small[4 * 1000010];
long long int arr[1000002], brr[1000002];
void update1(long long int ind, long long int left, long long int right,
             long long int val) {
  if (val > right || val < left) return;
  if (left == val && right == val) {
    tree_big[ind] = 1;
    return;
  }
  long long int mid = (left + right) / 2;
  update1(2 * ind, left, mid, val);
  update1(2 * ind + 1, mid + 1, right, val);
  tree_big[ind] = tree_big[2 * ind] + tree_big[2 * ind + 1];
}
void update2(long long int ind, long long int left, long long int right,
             long long int val) {
  if (val > right || val < left) return;
  if (left == val && right == val) {
    tree_small[ind] = 1;
    return;
  }
  long long int mid = (left + right) / 2;
  update2(2 * ind, left, mid, val);
  update2(2 * ind + 1, mid + 1, right, val);
  tree_small[ind] = tree_small[2 * ind] + tree_small[2 * ind + 1];
}
long long int query1(long long int ind, long long int left, long long int right,
                     long long int lef, long long int rig) {
  if (lef > right || rig < left) return 0;
  if (lef <= left && right <= rig) return tree_big[ind];
  long long int mid = (left + right) / 2;
  long long int x = query1(2 * ind, left, mid, lef, rig);
  long long int y = query1(2 * ind + 1, mid + 1, right, lef, rig);
  return x + y;
}
long long int query2(long long int ind, long long int left, long long int right,
                     long long int lef, long long int rig) {
  if (lef > right || rig < left) return 0;
  if (lef <= left && right <= rig) return tree_small[ind];
  long long int mid = (left + right) / 2;
  long long int x = query2(2 * ind, left, mid, lef, rig);
  long long int y = query2(2 * ind + 1, mid + 1, right, lef, rig);
  return x + y;
}
int main() {
  long long int n;
  cin >> n;
  long long int pos1[n], pos2[n];
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
    brr[i] = arr[i];
  }
  sort(brr, brr + n);
  for (long long int j = 0; j < n; j++) {
    arr[j] = lower_bound(brr, brr + n, arr[j]) - brr + 1;
  }
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) {
    pos1[i] = query1(1, 1, n, arr[i] + 1, n);
    update1(1, 1, n, arr[i]);
  }
  for (long long int i = n - 1; i >= 0; i--) {
    pos2[i] = query2(1, 1, n, 1, arr[i] - 1);
    update2(1, 1, n, arr[i]);
  }
  for (long long int i = 0; i < n; i++) ans += pos1[i] * pos2[i];
  cout << ans;
  return 0;
}
