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 ans = 0 for i in range(n+1) : for p in range(i+1) : q = i-p ans += A[p]*B[q] ans %= MOD print(ans)