#include <bits/stdc++.h>
using namespace std;
long long int n;
long long int a[123456];
map<long long int, long long int> ct;
int main() {
  cin >> n;
  for (long long int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long int ans = a[0] * a[1] * a[2];
  for (long long int i = 0; i < n; i++) ct[a[i]]++;
  int fans = 0;
  if (a[0] == a[1] && a[1] == a[2]) {
    cout << ct[a[0]] * (ct[a[0]] - 1) * (ct[a[0]] - 2) / 6 << endl;
  } else if (a[1] == a[2]) {
    cout << ct[a[1]] * (ct[a[1]] - 1) / 2 << endl;
  } else {
    cout << ct[a[2]] << endl;
  }
  return 0;
}
