n = int(input()) a = [int(input()) for i in range(n+1)] b = [int(input()) for i in range(n+1)] mod = 10**9+7 total = 0 a_sum = sum(a) for i in range(n, -1, -1): total = (total + a_sum*b[n-i]) % mod a_sum -= a[i] print(total)