#include <stdio.h>
#include <algorithm>
#define mod 1000000007
#define inv 166666668
int n;
int a[100005], s[100005];
int f(long long a, long long b, long long c)
{
a %= mod, b %= mod, c %= mod;
return (((a * b) % mod) * c) % mod;
}
int main()
{
long long ans = 0, sum = 0;
scanf("%d", &n);
for(int i=0; i<n; i++) {
scanf("%d", &a[i]);
sum = (sum + a[i]) % mod;
s[a[i]]++;
}
std::sort(a, a + n);
ans = f(sum, sum, sum);
for(int i=1; i<=100000; i++) {
ans = (ans - (f(s[i], s[i], s[i]) * f(i, i, i)) % mod) % mod;
ans = (ans + mod) % mod;
ans = (ans - 3 * f(f(s[i], s[i], sum - i * s[i]), i, i)) % mod;
ans = (ans + mod) % mod;
}
printf("%lld\n", (ans * inv) % mod);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1868 KB |
Output is correct |
2 |
Correct |
4 ms |
1868 KB |
Output is correct |
3 |
Correct |
4 ms |
1868 KB |
Output is correct |
4 |
Correct |
4 ms |
1868 KB |
Output is correct |
5 |
Correct |
4 ms |
1868 KB |
Output is correct |
6 |
Correct |
4 ms |
1868 KB |
Output is correct |
7 |
Correct |
4 ms |
1868 KB |
Output is correct |
8 |
Correct |
0 ms |
1868 KB |
Output is correct |
9 |
Correct |
4 ms |
1868 KB |
Output is correct |
10 |
Correct |
4 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1868 KB |
Output is correct |
2 |
Correct |
4 ms |
1868 KB |
Output is correct |
3 |
Correct |
4 ms |
1868 KB |
Output is correct |
4 |
Correct |
4 ms |
1868 KB |
Output is correct |
5 |
Correct |
4 ms |
1868 KB |
Output is correct |
6 |
Correct |
0 ms |
1868 KB |
Output is correct |
7 |
Correct |
4 ms |
1868 KB |
Output is correct |
8 |
Correct |
4 ms |
1868 KB |
Output is correct |
9 |
Incorrect |
4 ms |
1868 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
1868 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
1868 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
24 ms |
1868 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
24 ms |
1868 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |