#include <bits/stdc++.h>
using namespace std;
struct FenwickTree {
  int n;
  long long int tree[1000005];
  void init(int len) {
    n = len;
    for (int i = 1; i <= n; i++) {
      tree[i] = 0;
    }
  }
  void add(int index, long long int value) {
    while (index <= n) {
      tree[index] += value;
      index += (index & -index);
    }
  }
  long long int getPrefix(int index) {
    long long int ans = 0;
    while (index > 0) {
      ans += tree[index];
      index -= (index & -index);
    }
    return ans;
  }
};
FenwickTree BIT1;
FenwickTree BIT2;
int arr[1000005];
map<int, int> compressData;
int main() {
  int n, i, j, count;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> arr[i];
    compressData[arr[i]];
  }
  count = 1;
  for (auto &s : compressData) {
    compressData[s.first] = count++;
  }
  for (i = 1; i <= n; i++) {
    arr[i] = compressData[arr[i]];
  }
  BIT1.init(n);
  BIT2.init(n);
  long long int ans = 0;
  for (i = n; i >= 1; i--) {
    ans += BIT2.getPrefix(arr[i]);
    BIT2.add(arr[i], BIT1.getPrefix(arr[i]));
    BIT1.add(arr[i], 1);
  }
  cout << ans;
  return 0;
}
