#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int val[N], cnt[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", val + i);
  vector<int> vec;
  for (int i = 1; i <= n; i++) vec.push_back(val[i]);
  sort(vec.begin(), vec.end());
  vec.resize((unique(vec.begin(), vec.end()) - vec.begin()));
  for (int i = 1; i <= n; i++)
    cnt[lower_bound(vec.begin(), vec.end(), val[i]) - vec.begin()]++;
  if (cnt[0] >= 3) {
    printf("%I64d\n", (long long)cnt[0] * (cnt[0] - 1) * (cnt[0] - 2) / 6);
  } else if (cnt[0] + cnt[1] >= 3) {
    if (cnt[0] == 1) {
      printf("%I64d\n", (long long)cnt[1] * (cnt[1] - 1) / 2);
    } else {
      printf("%d\n", cnt[1]);
    }
  } else {
    printf("%d\n", cnt[2]);
  }
  return 0;
}
