#include <bits/stdc++.h>
using namespace std;
long long POW(long long A, long long N, long long MOD) {
  if (N == 0) return 1 % MOD;
  if (N == 1) return A % MOD;
  long long tmp = POW(A, N / 2, MOD) % MOD;
  if (N % 2)
    return ((tmp * tmp) % MOD * A % MOD) % MOD;
  else
    return (tmp * tmp) % MOD;
}
long long MUL(long long A, long long B, long long MOD) {
  long long r = 0;
  while (B) {
    r = (r + (A * (B % 2) % MOD)) % MOD;
    A = (A + A) % MOD;
    B /= 2;
  }
  return r;
}
long long GCD(long long A, long long B) { return B == 0 ? A : GCD(B, A % B); }
int dx[] = {0, -1, 0, 1, 0};
int dy[] = {0, 0, 1, 0, -1};
template <class X, class Y>
bool minimize(X &x, const Y &y) {
  X eps = 1e-9;
  if (x > y + eps) {
    x = y;
    return true;
  } else
    return false;
}
template <class X, class Y>
bool maximize(X &x, const Y &y) {
  X eps = 1e-9;
  if (x + eps < y) {
    x = y;
    return true;
  } else
    return false;
}
template <class T>
T Abs(const T &x) {
  return (x < 0 ? -x : x);
}
const int MAXN = 1e6 + 1000;
int N;
struct FenwickTree {
  int N;
  vector<long long> BIT;
  FenwickTree() { N = 0; }
  FenwickTree(int _N) {
    this->N = _N;
    BIT.assign(N + 10, 0);
  }
  void update(int u, long long val) {
    for (u; u; u -= u & -u) BIT[u] += val;
  }
  long long get(int u) {
    long long ANS = 0;
    for (u; u <= N + 5; u += u & -u) ANS += BIT[u];
    return ANS;
  }
};
int A[MAXN];
FenwickTree BIT[4];
long long dp[MAXN][4];
vector<int> H;
int GET(int val) {
  return lower_bound(H.begin(), H.end(), val) - H.begin() + 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> N;
  for (int i = (1), _b = (N); i <= _b; ++i) {
    cin >> A[i];
    dp[i][1] = 1;
    H.push_back(A[i]);
  }
  sort(H.begin(), H.end());
  for (int k = (2), _b = (3); k <= _b; ++k) {
    BIT[k - 1] = FenwickTree(N);
    for (int i = (1), _b = (N); i <= _b; ++i) {
      int ID = GET(A[i]);
      dp[i][k] = BIT[k - 1].get(ID + 1);
      BIT[k - 1].update(ID, dp[i][k - 1]);
    }
  }
  long long ANS = 0;
  for (int i = (1), _b = (N); i <= _b; ++i) ANS += 1ll * dp[i][3];
  cout << ANS << '\n';
  return 0;
}

### Prompt

Generate a CPP solution to the following problem:

The Romans have attacked again. This time they are much more than the Persians but Shapur is ready to defeat them. He says: "A lion is never afraid of a hundred sheep". 

Nevertheless Shapur has to find weaknesses in the Roman army to defeat them. So he gives the army a weakness number.

In Shapur's opinion the weakness of an army is equal to the number of triplets i, j, k such that i < j < k and ai > aj > ak where ax is the power of man standing at position x. The Roman army has one special trait — powers of all the people in it are distinct.

Help Shapur find out how weak the Romans are.

Input

The first line of input contains a single number n (3 ≤ n ≤ 106) — the number of men in Roman army. Next line contains n different positive integers ai (1 ≤ i ≤ n, 1 ≤ ai ≤ 109) — powers of men in the Roman army. 

Output

A single integer number, the weakness of the Roman army. 

Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).

Examples

Input

3
3 2 1


Output

1


Input

3
2 3 1


Output

0


Input

4
10 8 3 1


Output

4


Input

4
1 5 4 3


Output

1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long POW(long long A, long long N, long long MOD) {
  if (N == 0) return 1 % MOD;
  if (N == 1) return A % MOD;
  long long tmp = POW(A, N / 2, MOD) % MOD;
  if (N % 2)
    return ((tmp * tmp) % MOD * A % MOD) % MOD;
  else
    return (tmp * tmp) % MOD;
}
long long MUL(long long A, long long B, long long MOD) {
  long long r = 0;
  while (B) {
    r = (r + (A * (B % 2) % MOD)) % MOD;
    A = (A + A) % MOD;
    B /= 2;
  }
  return r;
}
long long GCD(long long A, long long B) { return B == 0 ? A : GCD(B, A % B); }
int dx[] = {0, -1, 0, 1, 0};
int dy[] = {0, 0, 1, 0, -1};
template <class X, class Y>
bool minimize(X &x, const Y &y) {
  X eps = 1e-9;
  if (x > y + eps) {
    x = y;
    return true;
  } else
    return false;
}
template <class X, class Y>
bool maximize(X &x, const Y &y) {
  X eps = 1e-9;
  if (x + eps < y) {
    x = y;
    return true;
  } else
    return false;
}
template <class T>
T Abs(const T &x) {
  return (x < 0 ? -x : x);
}
const int MAXN = 1e6 + 1000;
int N;
struct FenwickTree {
  int N;
  vector<long long> BIT;
  FenwickTree() { N = 0; }
  FenwickTree(int _N) {
    this->N = _N;
    BIT.assign(N + 10, 0);
  }
  void update(int u, long long val) {
    for (u; u; u -= u & -u) BIT[u] += val;
  }
  long long get(int u) {
    long long ANS = 0;
    for (u; u <= N + 5; u += u & -u) ANS += BIT[u];
    return ANS;
  }
};
int A[MAXN];
FenwickTree BIT[4];
long long dp[MAXN][4];
vector<int> H;
int GET(int val) {
  return lower_bound(H.begin(), H.end(), val) - H.begin() + 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> N;
  for (int i = (1), _b = (N); i <= _b; ++i) {
    cin >> A[i];
    dp[i][1] = 1;
    H.push_back(A[i]);
  }
  sort(H.begin(), H.end());
  for (int k = (2), _b = (3); k <= _b; ++k) {
    BIT[k - 1] = FenwickTree(N);
    for (int i = (1), _b = (N); i <= _b; ++i) {
      int ID = GET(A[i]);
      dp[i][k] = BIT[k - 1].get(ID + 1);
      BIT[k - 1].update(ID, dp[i][k - 1]);
    }
  }
  long long ANS = 0;
  for (int i = (1), _b = (N); i <= _b; ++i) ANS += 1ll * dp[i][3];
  cout << ANS << '\n';
  return 0;
}

```