import sys from itertools import accumulate n = int(input())+1 a = list(map(int, (sys.stdin.readline() for _ in [0]*n))) b = list(accumulate(map(int, sys.stdin))) mod = 10**9+7 print(sum(an*bn % mod for an, bn in zip(a, b[::-1])) % mod)