#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
map<int, int>::iterator it;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    m[x]++;
  }
  it = m.begin();
  int m1 = it->second;
  long long ans;
  if (m1 >= 3)
    ans = (1ll * m1 * (m1 - 1) * (m1 - 2)) / 6;
  else {
    it++;
    int m2 = it->second;
    if (m1 == 2)
      ans = m2;
    else if (m1 == 1) {
      if (m2 >= 2)
        ans = 1ll * m2 * (m2 - 1) / 2;
      else {
        it++;
        int m3 = it->second;
        ans = m3;
      }
    }
  }
  cout << ans;
  return 0;
}
