#include using namespace std; #define MOD (1000000000+7) long long power( long long x, int n ) { long long res = 1; while( n > 0 ) { if( n % 2 ) res = res * x % MOD; x = x * x % MOD; n /= 2; } return res; } int main() { int n; cin >> n; vector a( n + 1 ); for( int i = 0; i < n + 1; i++ ) { cin >> a[i]; } vector b( n + 1 ); for( int i = 0; i < n + 1; i++ ) { cin >> b[i]; } long long ans = 0; for( int i = 0; i < n + 1; i++ ) { for( int j = 0; j < i + 1; j++ ) { ans += a[j] * b[i - j] % MOD; ans %= MOD; } } cout << ans << endl; }