import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); long []cnt = new long[101]; Arrays.fill(cnt, 0); for(int i = 0; i < N; i++) { cnt[scan.nextInt()]++; } scan.close(); long s1 = 0; long s2 = 0; long s3 = 0; for(int i = 1; i <= 100; i++) { s1 += cnt[i]; s2 += cnt[i] * cnt[i]; s3 += cnt[i] * cnt[i] * cnt[i]; } long ans = (s1 * s1 * s1 -3 * s1 * s2 + 2 * s3)/ 6; long d = 1000000007L; System.out.println(ans % d); } }