#include <iostream>
#include <stdio.h>
using namespace std;
long long a[100009],b[100009];
int main()
{
long long n,input,MaX,i,SizE=0;
long long Sum=0,Mid=0,MiD=0;
scanf("%lld",&n);
scanf("%lld",&input); MaX=input; a[input]++;
for(i=2;i<=n;i++)
{
scanf("%d",&input);
a[input]++;
if(MaX<input) MaX = input;
}
for(i=1;i<=MaX;i++)if(i*a[i])
{
SizE++;
b[SizE]=i*a[i];
}
for(i=1;i<=SizE;i++) Mid += b[i];
Sum += Mid*Mid*Mid;
for(i=1;i<=SizE;i++) Sum += 2*b[i]*b[i]*b[i];
Mid = 0;
for(i=1;i<=SizE;i++){Mid+=b[i]*b[i]; MiD+=b[i];}
Sum -= 3*Mid*MiD;
printf("%lld",(Sum/6)%1000000007);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2940 KB |
Output is correct |
2 |
Correct |
0 ms |
2940 KB |
Output is correct |
3 |
Correct |
0 ms |
2940 KB |
Output is correct |
4 |
Correct |
0 ms |
2940 KB |
Output is correct |
5 |
Correct |
0 ms |
2940 KB |
Output is correct |
6 |
Correct |
0 ms |
2940 KB |
Output is correct |
7 |
Correct |
0 ms |
2940 KB |
Output is correct |
8 |
Correct |
0 ms |
2940 KB |
Output is correct |
9 |
Correct |
0 ms |
2940 KB |
Output is correct |
10 |
Correct |
0 ms |
2940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2940 KB |
Output is correct |
2 |
Correct |
0 ms |
2940 KB |
Output is correct |
3 |
Correct |
0 ms |
2940 KB |
Output is correct |
4 |
Correct |
0 ms |
2940 KB |
Output is correct |
5 |
Correct |
0 ms |
2940 KB |
Output is correct |
6 |
Correct |
0 ms |
2940 KB |
Output is correct |
7 |
Correct |
0 ms |
2940 KB |
Output is correct |
8 |
Correct |
0 ms |
2940 KB |
Output is correct |
9 |
Correct |
0 ms |
2940 KB |
Output is correct |
10 |
Correct |
0 ms |
2940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2940 KB |
Output is correct |
2 |
Correct |
0 ms |
2940 KB |
Output is correct |
3 |
Correct |
0 ms |
2940 KB |
Output is correct |
4 |
Correct |
0 ms |
2940 KB |
Output is correct |
5 |
Correct |
0 ms |
2940 KB |
Output is correct |
6 |
Correct |
0 ms |
2940 KB |
Output is correct |
7 |
Correct |
0 ms |
2940 KB |
Output is correct |
8 |
Correct |
0 ms |
2940 KB |
Output is correct |
9 |
Correct |
0 ms |
2940 KB |
Output is correct |
10 |
Correct |
0 ms |
2940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2940 KB |
Output is correct |
2 |
Correct |
0 ms |
2940 KB |
Output is correct |
3 |
Correct |
0 ms |
2940 KB |
Output is correct |
4 |
Correct |
0 ms |
2940 KB |
Output is correct |
5 |
Correct |
0 ms |
2940 KB |
Output is correct |
6 |
Correct |
0 ms |
2940 KB |
Output is correct |
7 |
Correct |
0 ms |
2940 KB |
Output is correct |
8 |
Correct |
0 ms |
2940 KB |
Output is correct |
9 |
Correct |
0 ms |
2940 KB |
Output is correct |
10 |
Correct |
0 ms |
2940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
2940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
2940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |