#include #define rep(i,n) for(int i=0;i<(n);++i) #define all(a) (a).begin(),(a).end() #define dunk(a) cout << (a) << endl using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(0); ll mod = 1000000007; int n; cin >> n; vector a(n + 1); vector b(n + 1); rep(i, n + 1) cin >> a[i]; rep(i, n + 1) cin >> b[i]; ll resa = 0; ll resb = 0; rep(i, n + 1) resa += a[i]; rep(i, n + 1) resb += b[i]; resa %= mod; resb %= mod; ll ans = resa * resb; ans %= mod; ll resa_no = 0; for (int i = 1; i < n + 1; ++i) { for (int j = n; j >= n - i + 1; --j) { resa_no += (a[i] * b[j])%mod; } } ans -= resa_no; while (ans < 0) { ans += mod; } dunk(ans); return 0; }