#include <bits/stdc++.h>
using namespace std;
long long n, sb, a[4], data1[100001], num[100001];
void merge(int l, int r) {
  int mid = (l + r) / 2;
  int i = l, j = mid + 1, k = 0;
  while (i <= mid && j <= r) {
    if (data1[i] < data1[j])
      num[k++] = data1[i++];
    else
      num[k++] = data1[j++];
  }
  while (i <= mid) num[k++] = data1[i++];
  while (j <= r) num[k++] = data1[j++];
  for (int p = 0; p < k; p++) data1[p + l] = num[p];
}
void sort(int l, int r) {
  if (l >= r) return;
  int mid = (l + r) / 2;
  sort(l, mid);
  sort(mid + 1, r);
  merge(l, r);
}
int main() {
  cin >> n;
  for (int j = 0; j < n; j++) cin >> data1[j];
  sort(0, n - 1);
  for (int i = 1; i <= 3; i++) {
    a[i] = 1;
    while (data1[sb] == data1[sb + 1] && sb < n - 1) {
      a[i]++;
      sb++;
    }
    sb++;
  }
  if (data1[0] == data1[1]) {
    if (data1[1] == data1[2])
      cout << a[1] * (a[1] - 1) * (a[1] - 2) / 6;
    else
      cout << a[2];
  } else {
    if (data1[1] == data1[2])
      cout << a[2] * (a[2] - 1) / 2;
    else
      cout << a[3];
  }
}
