#!/usr/bin/env perl use strict; use warnings; my $n = <>; chomp $n; my %h; my @v; my $s = <>; chomp $s; for my $x (split / /,$s) { if (!exists$h{$x}) { push @v, $x; } $h{$x}++; } my $count = 0; for (my $i = 0; $i < @v; $i++) { for (my $j = 0; $j < $i; $j++) { for (my $k = 0; $k < $j; $k++) { $count += $h{$v[$i]} * $h{$v[$j]} * $h{$v[$k]}; $count %= 1000000007; } } } print "$count\n";