#include<stdio.h>
#include<algorithm>
using namespace std;
int w[100001],n,i;
long long c,s,g,res,Mod=1000000007;
int main()
{
scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d",&w[i]);
sort(w,w+n);
for(i=n-1;i>=0;i--){
if(i!=n-1 && w[i]!=w[i+1])
{
g=(g+s*c*w[i+1])%Mod;
s=(s+c*w[i+1])%Mod;
c=0;
}
c++;
res=(res+g*w[i])%Mod;
}
printf("%lld\n",res);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1276 KB |
Output is correct |
2 |
Correct |
0 ms |
1276 KB |
Output is correct |
3 |
Correct |
0 ms |
1276 KB |
Output is correct |
4 |
Correct |
0 ms |
1276 KB |
Output is correct |
5 |
Correct |
0 ms |
1276 KB |
Output is correct |
6 |
Correct |
0 ms |
1276 KB |
Output is correct |
7 |
Correct |
0 ms |
1276 KB |
Output is correct |
8 |
Correct |
0 ms |
1276 KB |
Output is correct |
9 |
Correct |
0 ms |
1276 KB |
Output is correct |
10 |
Correct |
0 ms |
1276 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1276 KB |
Output is correct |
2 |
Correct |
0 ms |
1276 KB |
Output is correct |
3 |
Correct |
0 ms |
1276 KB |
Output is correct |
4 |
Correct |
0 ms |
1276 KB |
Output is correct |
5 |
Correct |
0 ms |
1276 KB |
Output is correct |
6 |
Correct |
0 ms |
1276 KB |
Output is correct |
7 |
Correct |
0 ms |
1276 KB |
Output is correct |
8 |
Correct |
0 ms |
1276 KB |
Output is correct |
9 |
Correct |
0 ms |
1276 KB |
Output is correct |
10 |
Correct |
0 ms |
1276 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1276 KB |
Output is correct |
2 |
Correct |
0 ms |
1276 KB |
Output is correct |
3 |
Correct |
0 ms |
1276 KB |
Output is correct |
4 |
Correct |
0 ms |
1276 KB |
Output is correct |
5 |
Correct |
0 ms |
1276 KB |
Output is correct |
6 |
Correct |
0 ms |
1276 KB |
Output is correct |
7 |
Correct |
0 ms |
1276 KB |
Output is correct |
8 |
Correct |
0 ms |
1276 KB |
Output is correct |
9 |
Correct |
0 ms |
1276 KB |
Output is correct |
10 |
Correct |
0 ms |
1276 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1276 KB |
Output is correct |
2 |
Correct |
0 ms |
1276 KB |
Output is correct |
3 |
Correct |
0 ms |
1276 KB |
Output is correct |
4 |
Correct |
0 ms |
1276 KB |
Output is correct |
5 |
Correct |
0 ms |
1276 KB |
Output is correct |
6 |
Correct |
0 ms |
1276 KB |
Output is correct |
7 |
Correct |
0 ms |
1276 KB |
Output is correct |
8 |
Correct |
0 ms |
1276 KB |
Output is correct |
9 |
Correct |
0 ms |
1276 KB |
Output is correct |
10 |
Correct |
0 ms |
1276 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
1276 KB |
Output is correct |
2 |
Correct |
3 ms |
1276 KB |
Output is correct |
3 |
Correct |
4 ms |
1276 KB |
Output is correct |
4 |
Correct |
19 ms |
1276 KB |
Output is correct |
5 |
Correct |
0 ms |
1276 KB |
Output is correct |
6 |
Correct |
14 ms |
1276 KB |
Output is correct |
7 |
Correct |
6 ms |
1276 KB |
Output is correct |
8 |
Correct |
25 ms |
1276 KB |
Output is correct |
9 |
Correct |
15 ms |
1276 KB |
Output is correct |
10 |
Correct |
21 ms |
1276 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
1276 KB |
Output is correct |
2 |
Correct |
1 ms |
1276 KB |
Output is correct |
3 |
Correct |
22 ms |
1276 KB |
Output is correct |
4 |
Correct |
4 ms |
1276 KB |
Output is correct |
5 |
Correct |
23 ms |
1276 KB |
Output is correct |
6 |
Correct |
4 ms |
1276 KB |
Output is correct |
7 |
Correct |
16 ms |
1276 KB |
Output is correct |
8 |
Correct |
17 ms |
1276 KB |
Output is correct |
9 |
Correct |
25 ms |
1276 KB |
Output is correct |
10 |
Correct |
16 ms |
1276 KB |
Output is correct |