import java.io.*; import java.util.*; import java.util.function.*; final class Solver { void solve(Supplier sc) { int N = Integer.parseInt(sc.get()); var A = new int[N]; Arrays.setAll(A, $ -> Integer.parseInt(sc.get())); var bucket = new int[101]; for (int i : A) { bucket[i]++; } long combination = 0; for (int i = 0; i < bucket.length; i++) { int low = bucket[i]; if (low > 0) for (int j = i + 1; j < bucket.length; j++) { int middle = bucket[j]; if (middle > 0) for (int k = j + 1; k < bucket.length; k++) { int high = bucket[k]; if (high <= 0) continue; combination += (long) low * middle * high; } } } System.out.println(combination % MOD); } static final int MOD = 1000000007; int mod(long val) { return Math.floorMod(val, MOD); } int add(long a, long b) { return mod(a + b); } int sub(long a, long b) { return add(a, -b); } int mul(long a, long b) { return mod(a * b); } int pow(long a, long n) { int res = 1; for (; n > 0; n /= 2) { if (n % 2 == 1) res = mul(res, a); a = mul(a, a); } return res; } long[] factorial; long[] invFactorial; long[] inverse; void initFactorial(int max) { factorial = new long[max]; invFactorial = new long[max]; inverse = new long[max]; factorial[0] = factorial[1] = 1; invFactorial[0] = invFactorial[1] = 1; inverse[1] = 1; for (int i = 2; i < max; i++) { factorial[i] = mul(factorial[i - 1], i); long inv = inverse[i] = sub(MOD, mul(inverse[MOD % i], MOD / i)); invFactorial[i] = mul(invFactorial[i - 1], inv); } } int div(long a, int b) { return mul(a, inverse != null && b < inverse.length ? inverse[b] : pow(b, MOD - 2)); } int ncr(int n, int r) { if (n < r) return 0; if (n < 0 || r < 0) return 0; return mul(factorial[n], mul(invFactorial[r], invFactorial[n - r])); } } class Main { public static void main(String... args) { System.setOut(new PrintStream(new BufferedOutputStream(System.out))); var reader = new BufferedReader(new InputStreamReader(System.in)); new Solver().solve(new Supplier<>() { StringTokenizer line; public String get() { while (line == null || !line.hasMoreTokens()) try { line = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new UncheckedIOException(e); } return line.nextToken(); } }); System.out.flush(); } }