program main implicit none integer::N,dist(1:100),i,j,total,res,res2 integer,allocatable::A(:) data dist/100*0/,total/0/ read *,N allocate(A(N)) read *,A do i=1, N dist(A(i)) = dist(A(i)) + 1 end do res = N do i=1,100 if(dist(i).eq.0) cycle res = res - dist(i) res2 = res do j=i+1,100 if(dist(j).eq.0) cycle res2 = res2 - dist(j) total = total + dist(i)*dist(j)*res2 total = MOD(total,10**9+7) if(res2.eq.0) exit end do end do print '(i0)', total end program main