long a,b,c,i;x[101];main(k){for(gets(x);~scanf("%d",&i);x[i]++);for(;k<101;c+=i*i*i)a+=i=x[k++],b+=i*i;i=!printf("%d",(a*a*a-3*a*b+2*c)/6%(i=1e9+7));}