N = int(input()) M = int(input()) A = list(map(int, input().split())) a = sum(A) ans = 0 from math import gcd P = 10 ** 9 + 7 for b in map(int, input().split()): x = 0 for i in A: g = gcd(i, b) x -= b - g x += a * (b + 1) ans += x ans %= P print(ans)