#include <bits/stdc++.h>
using namespace std;
long long inline gcd(long long x, long long y) {
  return !y ? (long long)abs(x) : gcd(y, x % y);
}
long long inline lcm(long long a, long long b) {
  return ((long long)abs((a / gcd(a, b)) * b));
}
double inline cartesian_dist(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
long long bigmod(long long b, long long p, long long m) {
  if (!p)
    return 1 % m;
  else if (p & 1)
    return (((b % m) + m) % m * bigmod(b, p - 1, m)) % m;
  else {
    long long ret = bigmod(b, p / 2, m);
    return (ret * ret) % m;
  }
}
long long inverse(long long a, long long m) { return bigmod(a, m - 2, m); }
long long extended(long long a, long long m) {
  long long oldr = a, r = m, oldans = 1, ans = 0, quotient;
  while (r) {
    quotient = oldr / r;
    oldr = oldr - r * quotient;
    swap(oldr, r);
    oldans = oldans - ans * quotient;
    swap(oldans, ans);
  }
  return ((oldans % m) + m) % m;
}
const double PI = acos(-1.0);
const double eps = 10E-12;
long long nC3(long long x) { return (x * (x - 1) * (x - 2)) / 6; }
long long nC2(long long x) { return (x * (x - 1)) / 2; }
long long nC1(long long x) { return x; }
int main() {
  long long n;
  scanf("%lld", &n);
  long long arr[n + 5];
  for (int i = 1; i <= n; i++) scanf("%lld", &arr[i]);
  sort(arr + 1, arr + n + 1);
  long long min1 = arr[1];
  long long min2 = arr[2];
  long long min3 = arr[3];
  if (min1 == min2) {
    if (min2 == min3) {
      long long totalMin3 = (upper_bound(arr + 1, arr + n + 1, min3) -
                             lower_bound(arr + 1, arr + n + 1, min3));
      totalMin3 = nC3(totalMin3);
      printf("%lld", totalMin3);
      printf("\n");
    } else {
      long long totalMin2 = (upper_bound(arr + 1, arr + n + 1, min2) -
                             lower_bound(arr + 1, arr + n + 1, min2));
      totalMin2 = nC2(totalMin2);
      long long totalMin3 = (upper_bound(arr + 1, arr + n + 1, min3) -
                             lower_bound(arr + 1, arr + n + 1, min3));
      totalMin3 = nC1(totalMin3);
      printf("%lld", totalMin2 * totalMin3);
      printf("\n");
    }
  } else {
    if (min2 == min3) {
      long long totalMin1 = (upper_bound(arr + 1, arr + n + 1, min1) -
                             lower_bound(arr + 1, arr + n + 1, min1));
      totalMin1 = nC1(totalMin1);
      long long totalMin3 = (upper_bound(arr + 1, arr + n + 1, min3) -
                             lower_bound(arr + 1, arr + n + 1, min3));
      totalMin3 = nC2(totalMin3);
      printf("%lld", totalMin1 * totalMin3);
      printf("\n");
    } else {
      long long totalMin1 = (upper_bound(arr + 1, arr + n + 1, min1) -
                             lower_bound(arr + 1, arr + n + 1, min1));
      totalMin1 = nC1(totalMin1);
      long long totalMin2 = (upper_bound(arr + 1, arr + n + 1, min2) -
                             lower_bound(arr + 1, arr + n + 1, min2));
      totalMin2 = nC1(totalMin2);
      long long totalMin3 = (upper_bound(arr + 1, arr + n + 1, min3) -
                             lower_bound(arr + 1, arr + n + 1, min3));
      totalMin3 = (totalMin3);
      printf("%lld", totalMin1 * totalMin2 * totalMin3);
      printf("\n");
    }
  }
  return 0;
}

### Prompt

Your challenge is to write a CPP solution to the following problem:

After returning from the army Makes received a gift — an array a consisting of n positive integer numbers. He hadn't been solving problems for a long time, so he became interested to answer a particular question: how many triples of indices (i, j, k) (i < j < k), such that ai·aj·ak is minimum possible, are there in the array? Help him with it!

Input

The first line of input contains a positive integer number n (3 ≤ n ≤ 105) — the number of elements in array a. The second line contains n positive integer numbers ai (1 ≤ ai ≤ 109) — the elements of a given array.

Output

Print one number — the quantity of triples (i, j, k) such that i, j and k are pairwise distinct and ai·aj·ak is minimum possible.

Examples

Input

4
1 1 1 1


Output

4


Input

5
1 3 2 3 4


Output

2


Input

6
1 3 3 1 3 2


Output

1

Note

In the first example Makes always chooses three ones out of four, and the number of ways to choose them is 4.

In the second example a triple of numbers (1, 2, 3) is chosen (numbers, not indices). Since there are two ways to choose an element 3, then the answer is 2.

In the third example a triple of numbers (1, 1, 2) is chosen, and there's only one way to choose indices.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long inline gcd(long long x, long long y) {
  return !y ? (long long)abs(x) : gcd(y, x % y);
}
long long inline lcm(long long a, long long b) {
  return ((long long)abs((a / gcd(a, b)) * b));
}
double inline cartesian_dist(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
long long bigmod(long long b, long long p, long long m) {
  if (!p)
    return 1 % m;
  else if (p & 1)
    return (((b % m) + m) % m * bigmod(b, p - 1, m)) % m;
  else {
    long long ret = bigmod(b, p / 2, m);
    return (ret * ret) % m;
  }
}
long long inverse(long long a, long long m) { return bigmod(a, m - 2, m); }
long long extended(long long a, long long m) {
  long long oldr = a, r = m, oldans = 1, ans = 0, quotient;
  while (r) {
    quotient = oldr / r;
    oldr = oldr - r * quotient;
    swap(oldr, r);
    oldans = oldans - ans * quotient;
    swap(oldans, ans);
  }
  return ((oldans % m) + m) % m;
}
const double PI = acos(-1.0);
const double eps = 10E-12;
long long nC3(long long x) { return (x * (x - 1) * (x - 2)) / 6; }
long long nC2(long long x) { return (x * (x - 1)) / 2; }
long long nC1(long long x) { return x; }
int main() {
  long long n;
  scanf("%lld", &n);
  long long arr[n + 5];
  for (int i = 1; i <= n; i++) scanf("%lld", &arr[i]);
  sort(arr + 1, arr + n + 1);
  long long min1 = arr[1];
  long long min2 = arr[2];
  long long min3 = arr[3];
  if (min1 == min2) {
    if (min2 == min3) {
      long long totalMin3 = (upper_bound(arr + 1, arr + n + 1, min3) -
                             lower_bound(arr + 1, arr + n + 1, min3));
      totalMin3 = nC3(totalMin3);
      printf("%lld", totalMin3);
      printf("\n");
    } else {
      long long totalMin2 = (upper_bound(arr + 1, arr + n + 1, min2) -
                             lower_bound(arr + 1, arr + n + 1, min2));
      totalMin2 = nC2(totalMin2);
      long long totalMin3 = (upper_bound(arr + 1, arr + n + 1, min3) -
                             lower_bound(arr + 1, arr + n + 1, min3));
      totalMin3 = nC1(totalMin3);
      printf("%lld", totalMin2 * totalMin3);
      printf("\n");
    }
  } else {
    if (min2 == min3) {
      long long totalMin1 = (upper_bound(arr + 1, arr + n + 1, min1) -
                             lower_bound(arr + 1, arr + n + 1, min1));
      totalMin1 = nC1(totalMin1);
      long long totalMin3 = (upper_bound(arr + 1, arr + n + 1, min3) -
                             lower_bound(arr + 1, arr + n + 1, min3));
      totalMin3 = nC2(totalMin3);
      printf("%lld", totalMin1 * totalMin3);
      printf("\n");
    } else {
      long long totalMin1 = (upper_bound(arr + 1, arr + n + 1, min1) -
                             lower_bound(arr + 1, arr + n + 1, min1));
      totalMin1 = nC1(totalMin1);
      long long totalMin2 = (upper_bound(arr + 1, arr + n + 1, min2) -
                             lower_bound(arr + 1, arr + n + 1, min2));
      totalMin2 = nC1(totalMin2);
      long long totalMin3 = (upper_bound(arr + 1, arr + n + 1, min3) -
                             lower_bound(arr + 1, arr + n + 1, min3));
      totalMin3 = (totalMin3);
      printf("%lld", totalMin1 * totalMin2 * totalMin3);
      printf("\n");
    }
  }
  return 0;
}

```