#include <bits/stdc++.h>
using namespace std;
long long C(long long k, long long n) {
  long long res = 1;
  for (int i = 1; i <= k; i++) {
    res = res * (n - i + 1) / i;
  }
  return res;
}
int main() {
  int n, counting = 1, dis = 1, count[4];
  long a[100001];
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  if (a[1] == a[2] && a[2] == a[3]) {
    for (int i = 2; i <= n; i++) {
      if (a[i] == a[1])
        counting++;
      else
        break;
    }
    cout << C(3, counting);
  }
  if (a[1] != a[2] && a[2] == a[3]) {
    for (int i = 3; i <= n; i++) {
      if (a[i] == a[2]) counting++;
    }
    cout << C(2, counting);
  }
  if (a[1] != a[2] && a[2] != a[3]) {
    for (int i = 4; i <= n; i++) {
      if (a[i] == a[3]) counting++;
    }
    cout << counting;
  }
  if (a[1] == a[2] && a[2] != a[3]) {
    for (int i = 4; i <= n; i++) {
      if (a[i] == a[3]) counting++;
    }
    cout << counting;
  }
}
