#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream &operator>>(istream &in, vector<T> &a) {
  for (int i = 0; i < a.size(); ++i) in >> a[i];
  return in;
}
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &a) {
  for (int i = 0; i < a.size(); ++i) out << a[i] << " ";
  return out;
}
int main() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  sort(arr.begin(), arr.end());
  int x = arr[0], y = arr[1], z = arr[2];
  long long int answ_x = 0, answ_y = 0, answ_z = 0;
  for (int i = 0; i < n; ++i) {
    if (arr[i] == x) answ_x++;
    if (arr[i] == y) answ_y++;
    if (arr[i] == z) answ_z++;
  }
  if (x == y && y == z)
    cout << (answ_x) * (answ_x - 1) * (answ_x - 2) / 6;
  else if (x == y)
    cout << (answ_x) * (answ_x - 1) * answ_z / 2;
  else if (y == z)
    cout << (answ_y) * (answ_y - 1) * answ_x / 2;
  else
    cout << answ_x * answ_y * answ_z;
  cout << endl;
  return 0;
  ;
}
