#include <bits/stdc++.h>
const long long N = 100100;
const long long MAX = 1000000100;
using namespace std;
long long a[N] = {0};
int main() {
  long long n;
  while (scanf("%lld", &n) != EOF) {
    map<long long, long long> num;
    for (long long i = 0; i < n; i++) {
      scanf("%lld", &a[i]);
      num[a[i]]++;
    }
    sort(a, a + n);
    long long min1 = MAX + 1, min2 = MAX + 2, min3 = MAX + 3;
    for (long long i = 0; i < n; i++) {
      if (a[i] < min1) {
        min1 = a[i];
      } else if (a[i] > min1 && a[i] < min2) {
        min2 = a[i];
      } else if (a[i] > min2 && a[i] < min3) {
        min3 = a[i];
        break;
      }
    }
    if (num[min1] >= 3) {
      long long sum = 1;
      for (long long i = 3; i >= 1; i--) sum *= num[min1]--;
      cout << sum / 6 << endl;
    } else if (num[min1] == 2) {
      cout << num[min2] << endl;
    } else {
      if (num[min2] >= 2) {
        long long sum = 1;
        for (long long i = 2; i >= 1; i--) sum *= num[min2]--;
        cout << sum / 2 << endl;
      } else {
        cout << num[min3] << endl;
      }
    }
  }
  return 0;
}
