# c_0 = a_0 * b_0 # c_1 = a_0 * b_1 + a_1 * b_0 # c_2 = a_0 * b_2 + a_1 * b_1 + a_2 * b_0 # c_3 = a_0 * b_3 + a_1 * b_2 + a_2 * b_1 + a_3 * b_0 # c_4 = a_0 * b_4 + a_1 * b_3 + a_2 * b_2 + a_3 * b_1 + a_4 * b_0 # ... # c_n = \sum_{i = 0}^{n} ( a_{i} * \sum_{0}^{n-i} b_{i} ) MOD = 1000_000_007 n=gets.to_i A = (0 .. n).map{ gets.to_i } B = (0 .. n).map{ gets.to_i } (1 .. n).each do |i| B[i] += B[i - 1] end puts (0 .. n).inject(0){|s, i| (s + A[i] * B[n - i]) % MOD } % MOD