#include <bits/stdc++.h>
using namespace std;
long long data[100010];
int main() {
  long long n, i, j, k, sum;
  sum = 1;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> data[i];
  }
  sort(data + 1, data + 1 + n);
  if (data[1] == data[3]) {
    sum = 3;
    for (i = 4; i <= n; i++) {
      if (data[i] == data[3]) sum++;
    }
    k = (sum - 2) * (sum - 1) * sum / 6;
    cout << k << endl;
  } else if (data[1] != data[2] && data[2] == data[3]) {
    sum = 2;
    for (i = 4; i <= n; i++) {
      if (data[i] == data[3]) sum++;
    }
    k = (sum - 1) * sum / 2;
    cout << k << endl;
  } else if (data[1] == data[2] && data[2] != data[3]) {
    sum = 1;
    for (i = 4; i <= n; i++) {
      if (data[i] == data[3]) {
        sum++;
      }
    }
    cout << sum << endl;
  } else if (data[1] != data[2] && data[2] != data[3]) {
    for (i = 4; i <= n; i++) {
      if (data[i] == data[3]) {
        sum++;
      }
    }
    cout << sum << endl;
  }
  return 0;
}
