#include <bits/stdc++.h>
using namespace std;
long long ar[109];
long long dp[109];
int main() {
  vector<int> v;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int val;
    cin >> val;
    v.push_back(val);
  }
  vector<int>::const_iterator it;
  it = v.begin();
  sort(v.begin(), v.end());
  if (v[0] == v[2]) {
    long long up = (long long)(upper_bound(v.begin(), v.end(), v[0]) - it);
    cout << (up * (up - 1) * (up - 2)) / 6 << '\n';
  } else if (v[0] == v[1]) {
    long long up =
        (long long)(upper_bound(v.begin(), v.end(), v[2]) - (it + 2));
    cout << up << endl;
  } else if (v[1] == v[2]) {
    long long up =
        (long long)(upper_bound(v.begin(), v.end(), v[1]) - (it + 1));
    cout << (up * (up - 1) / 2) << endl;
  } else {
    long long up =
        (long long)(upper_bound(v.begin(), v.end(), v[2]) - (it + 2));
    cout << (up) << endl;
  }
}
