#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i;
  cin >> n;
  vector<long long int> v(n);
  map<long long int, long long int> m;
  for (i = 0; i < n; i++) {
    cin >> v[i];
    m[v[i]]++;
  }
  sort(v.begin(), v.end());
  if (v[0] == v[1] && v[1] == v[2]) {
    long long int ans = (m[v[0]] * (m[v[0]] - 1) * (m[v[0]] - 2)) / 6;
    cout << ans;
  } else if (v[0] == v[1] && v[1] != v[2]) {
    long long int ans = (m[v[0]] * (m[v[0]] - 1) * (m[v[2]])) / 2;
    cout << ans << endl;
  } else if (v[0] != v[1] && v[1] == v[2]) {
    long long int ans = (m[v[0]] * (m[v[2]]) * (m[v[2]] - 1)) / 2;
    cout << ans << endl;
  } else {
    long long int ans = (m[v[0]] * (m[v[1]]) * (m[v[2]]));
    cout << ans << endl;
  }
}
