30 lines
811 B
C++
30 lines
811 B
C++
#include <iostream>
|
|
|
|
using namespace std;
|
|
long long alpha[500005], beta[500005];
|
|
long long pre_alpha[500005], pre_beta[500005];
|
|
long long sum_alpha, sum_beta;
|
|
long long ans;
|
|
|
|
const int mod = 1000000007;
|
|
|
|
int main() {
|
|
int n;
|
|
cin >> n;
|
|
for (int i = 1; i <= n; ++i) {
|
|
cin >> alpha[i];
|
|
pre_alpha[i] = (pre_alpha[i - 1] + alpha[i]) % mod;
|
|
}
|
|
for (int i = 1; i <= n; ++i) {
|
|
cin >> beta[i];
|
|
pre_beta[i] = (pre_beta[i - 1] + beta[i]) % mod;
|
|
}
|
|
for (int i = 1; i <= n; i++) {
|
|
(ans += (((n + 1) * pre_alpha[i]) % mod) * pre_beta[i]) %= mod;
|
|
sum_alpha = (sum_alpha + pre_alpha[i]) % mod;
|
|
sum_beta = (sum_beta + pre_beta[i]) % mod;
|
|
}
|
|
long long tot = (sum_alpha * sum_beta) % mod;
|
|
ans = (ans - tot + mod) % mod;
|
|
cout << ans;
|
|
} |