<reponame>ryosuke0825/atcoder_python<gh_stars>0
N = int(input())
A = list(map(int, input().split()))
MAD = 1000000007

A.sort()
ans = A[0]+1
ans %= MAD
for i in range(1, N):
    ans *= (A[i]-A[i-1]+1)
    ans %= MAD
print(ans)

N = int(input())
A = list(map(int, input().split()))
MAD = 1000000007

A.sort()
ans = A[0]+1
ans %= MAD
for i in range(1, N):
    ans *= (A[i]-A[i-1]+1)
    ans %= MAD
print(ans)