#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int A[n];
  for (long long int i = 0; i < n; i++) cin >> A[i];
  sort(A, A + n);
  long long int first = 0, sec = 0, three = 0;
  for (long long int i = 0; i < n; i++) {
    if (A[i] == A[0]) first++;
  }
  for (long long int i = 1; i < n; i++) {
    if (A[i] == A[1]) sec++;
  }
  for (long long int i = 2; i < n; i++) {
    if (A[i] == A[2]) three++;
  }
  if (A[0] == A[1] && A[1] == A[2]) {
    cout << first * (first - 1) * (first - 2) / 6;
    return 0;
  }
  if (A[0] != A[1] && A[1] == A[2]) {
    cout << sec * (sec - 1) / 2;
    return 0;
  }
  if (A[0] == A[1] && A[1] != A[2])
    ;
  {
    cout << three;
    return 0;
  }
  cout << 1;
  return 0;
}
