#include int main() { int n; std::cin >> n; int *a = new int[n]; for(int i = 0; i < n; i++) std::cin >> a[i]; unsigned long long ret = 0; for(int i = 0; i < (n - 2); i++) { for(int j = i + 1; j < (n - 1); j++) { for(int k = j + 1; k < n; k++) { if((a[i] == a[j]) || (a[j] == a[k]) || (a[k] == a[i])) continue; ret++; } } } ret %= 1000000007; std::cout << ret << std::endl; delete[] a; return 0; }