#include #include #include using namespace std; long long CalcCombination(long long n, long long r) { long long divided = 1; long long divisor = 1; for (int i = 0; i < r; i++) { divided *= n - i; divisor *= r - i; } return divided / divisor; } int main() { int n; cin >> n; unordered_map group_nums; string len; for (int i = 0; i < n; i++) { cin >> len; group_nums[len]++; } long long count_overlap = 0; for (auto pair : group_nums) { if (pair.second > 1) { count_overlap += CalcCombination(pair.second, 2) * CalcCombination(n - pair.second, 1); if (pair.second > 2) { count_overlap += CalcCombination(pair.second, 3); } } } long long total_combination = CalcCombination(n, 3) - count_overlap; cout << total_combination % 1000000007 << endl; return 0; }