#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimization("unroll-loops")
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const long long N = 1e5 + 5;
long long ans, n, a[N];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  map<long long, long long> mp;
  for (long long i = 1; i <= n; i++) mp[a[i]] += 1;
  vector<pair<long long, long long> > v;
  for (pair<long long, long long> ele : mp) v.push_back(ele);
  sort(v.begin(), v.end());
  long long c1 = v[0].second;
  if (c1 >= 3) return cout << (c1 * (c1 - 1) * (c1 - 2)) / 6, 0;
  if (c1 == 2) return cout << v[1].second, 0;
  long long c2 = v[1].second;
  if (c2 >= 2) return cout << (c2 * (c2 - 1)) / 2, 0;
  long long c3 = v[2].second;
  cout << c3;
}
