#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long n;
map<long long, long long> a;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long c;
    cin >> c;
    a[c]++;
  }
  auto fi = *a.begin();
  if (fi.second >= 3) {
    long long k = fi.second;
    cout << (k * (k - 1) * (k - 2)) / 6 << endl;
  } else if (fi.second == 2) {
    long long F = fi.second;
    long long S = (*next(a.begin())).second;
    cout << (F * (F - 1)) / 2 * S << endl;
  } else {
    long long F = fi.second;
    long long S = (*next(a.begin())).second;
    if (S >= 2) {
      cout << F * (S * (S - 1)) / 2 << endl;
    } else {
      long long T = (*next(next(a.begin()))).second;
      cout << F * S * T << endl;
    }
  }
  return 0;
}
