#include <bits/stdc++.h>
using namespace std;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << "\t";
    return *this;
  }
} dbg;
template <class T>
void setmax(T& a, T b) {
  if (a < b) a = b;
}
template <class T>
void setmin(T& a, T b) {
  if (b < a) a = b;
}
template <class T>
T Abs(T x) {
  return x > 0 ? x : -x;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class T>
inline T Mod(T n, T m) {
  return (n % m + m) % m;
}
template <class T>
string toString(T n) {
  ostringstream oss;
  oss << n;
  oss.flush();
  return oss.str();
}
long long toInt(string s) {
  long long r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
bool isVowel(char ch) {
  ch = tolower(ch);
  if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
    return true;
  return false;
}
bool isUpper(char c) { return c >= 'A' && c <= 'Z'; }
bool isLower(char c) { return c >= 'a' && c <= 'z'; }
long long Pow(long long B, long long P) {
  long long R = 1;
  while (P > 0) {
    if (P % 2 == 1) R = (R * B);
    P /= 2;
    B = (B * B);
  }
  return R;
}
long long BigMod(long long B, long long P, long long M) {
  long long R = 1;
  while (P > 0) {
    if (P % 2 == 1) {
      R = (R * B) % M;
    }
    P /= 2;
    B = (B * B) % M;
  }
  return (int)R;
}
void binprint(long long mask, long long n) {
  long long i;
  string s = "";
  do {
    s += (mask % 2 + '0');
    mask /= 2;
  } while (mask);
  reverse(s.begin(), s.end());
  s = string(max(n - (int)s.size(), 0LL), '0') + s;
  for (i = (int)s.size() - n; i < (int)s.size(); i++) printf("%c", s[i]);
  printf("\n");
}
void ASCII_Chart() {
  long long i, j, k;
  printf("ASCII Chart:(30-129)\n");
  for (i = 30; i < 50; i++) {
    for (j = 0; j < 5; j++) {
      k = i + j * 20;
      printf("%3d---> '%c'   ", k, k);
    }
    printf("\n");
  }
}
struct pq {
  long long val, ind;
  pq(long long val = 0, long long ind = 0) {
    this->val = val;
    this->ind = ind;
  }
};
pq arr[1100000];
bool comp(pq a, pq b) {
  if (a.val != b.val) return a.val > b.val;
  return a.ind > b.ind;
}
long long tree[1100000], N;
void update(long long ind, long long val) {
  while (ind < N) {
    tree[ind] += val;
    ind += (ind & -ind);
  }
}
long long read(long long ind) {
  long long sum = 0;
  while (ind > 0) {
    sum += tree[ind];
    ind -= (ind & -ind);
  }
  return sum;
}
long long query(long long i, long long j) { return read(j) - read(i - 1); }
long long dp[1100000];
int main() {
  long long i, j, test, Case = 1, val, ind, sum;
  while (scanf("%I64d", &N) == 1) {
    for (i = 0; i < N; i++) {
      scanf("%I64d", &val);
      arr[i] = pq(val, i);
    }
    sort(&arr[0], &arr[N], comp);
    memset(tree, 0, sizeof(tree));
    for (i = 0; i < N; i++) {
      ind = arr[i].ind;
      if (ind == 0)
        dp[i] = 0;
      else
        dp[i] = query(1, ind);
      update(ind + 1, 1);
    }
    memset(tree, 0, sizeof(tree));
    sum = 0;
    for (i = 0; i < N; i++) {
      ind = arr[i].ind;
      if (ind == 0) continue;
      sum += query(1, ind);
      update(ind + 1, dp[i]);
    }
    printf("%I64d\n", sum);
  }
  return 0;
}

### Prompt

Construct a Cpp code solution to the problem outlined:

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;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << "\t";
    return *this;
  }
} dbg;
template <class T>
void setmax(T& a, T b) {
  if (a < b) a = b;
}
template <class T>
void setmin(T& a, T b) {
  if (b < a) a = b;
}
template <class T>
T Abs(T x) {
  return x > 0 ? x : -x;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class T>
inline T Mod(T n, T m) {
  return (n % m + m) % m;
}
template <class T>
string toString(T n) {
  ostringstream oss;
  oss << n;
  oss.flush();
  return oss.str();
}
long long toInt(string s) {
  long long r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
bool isVowel(char ch) {
  ch = tolower(ch);
  if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
    return true;
  return false;
}
bool isUpper(char c) { return c >= 'A' && c <= 'Z'; }
bool isLower(char c) { return c >= 'a' && c <= 'z'; }
long long Pow(long long B, long long P) {
  long long R = 1;
  while (P > 0) {
    if (P % 2 == 1) R = (R * B);
    P /= 2;
    B = (B * B);
  }
  return R;
}
long long BigMod(long long B, long long P, long long M) {
  long long R = 1;
  while (P > 0) {
    if (P % 2 == 1) {
      R = (R * B) % M;
    }
    P /= 2;
    B = (B * B) % M;
  }
  return (int)R;
}
void binprint(long long mask, long long n) {
  long long i;
  string s = "";
  do {
    s += (mask % 2 + '0');
    mask /= 2;
  } while (mask);
  reverse(s.begin(), s.end());
  s = string(max(n - (int)s.size(), 0LL), '0') + s;
  for (i = (int)s.size() - n; i < (int)s.size(); i++) printf("%c", s[i]);
  printf("\n");
}
void ASCII_Chart() {
  long long i, j, k;
  printf("ASCII Chart:(30-129)\n");
  for (i = 30; i < 50; i++) {
    for (j = 0; j < 5; j++) {
      k = i + j * 20;
      printf("%3d---> '%c'   ", k, k);
    }
    printf("\n");
  }
}
struct pq {
  long long val, ind;
  pq(long long val = 0, long long ind = 0) {
    this->val = val;
    this->ind = ind;
  }
};
pq arr[1100000];
bool comp(pq a, pq b) {
  if (a.val != b.val) return a.val > b.val;
  return a.ind > b.ind;
}
long long tree[1100000], N;
void update(long long ind, long long val) {
  while (ind < N) {
    tree[ind] += val;
    ind += (ind & -ind);
  }
}
long long read(long long ind) {
  long long sum = 0;
  while (ind > 0) {
    sum += tree[ind];
    ind -= (ind & -ind);
  }
  return sum;
}
long long query(long long i, long long j) { return read(j) - read(i - 1); }
long long dp[1100000];
int main() {
  long long i, j, test, Case = 1, val, ind, sum;
  while (scanf("%I64d", &N) == 1) {
    for (i = 0; i < N; i++) {
      scanf("%I64d", &val);
      arr[i] = pq(val, i);
    }
    sort(&arr[0], &arr[N], comp);
    memset(tree, 0, sizeof(tree));
    for (i = 0; i < N; i++) {
      ind = arr[i].ind;
      if (ind == 0)
        dp[i] = 0;
      else
        dp[i] = query(1, ind);
      update(ind + 1, 1);
    }
    memset(tree, 0, sizeof(tree));
    sum = 0;
    for (i = 0; i < N; i++) {
      ind = arr[i].ind;
      if (ind == 0) continue;
      sum += query(1, ind);
      update(ind + 1, dp[i]);
    }
    printf("%I64d\n", sum);
  }
  return 0;
}

```