#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int maxm = 1e6;
long long a[maxn];
map<long long, long long> w;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
    w[a[i]]++;
  }
  sort(a + 1, a + 1 + n);
  if (a[1] == a[2] && a[2] == a[3]) {
    long long ans = w[a[1]];
    cout << ((ans - 1) * (ans - 2) * ans) / 6 << endl;
  } else if (a[1] == a[2] && a[1] != a[3]) {
    long long ans1 = w[a[1]];
    long long ans2 = w[a[3]];
    cout << (ans1 * (ans1 - 1) / 2) * ans2 << endl;
  } else if (a[1] != a[2] && a[2] == a[3]) {
    long long ans1 = w[a[2]];
    long long ans2 = w[a[1]];
    cout << (ans1 * (ans1 - 1) / 2) * ans2 << endl;
  } else {
    long long ans1 = w[a[1]];
    long long ans2 = w[a[2]];
    long long ans3 = w[a[3]];
    cout << ans1 * ans2 * ans3 << endl;
  }
}
