mod = 10 ** 9 + 7 def sumofDiff(n, A): A.sort() s = 0 ret = 0 for i, v in enumerate(A): ret += i * v - s ret %= mod s += v s %= mod return ret m = 10 ** 9 + 1 pow2 = pow(2, mod - 2, mod) def sumofMax(n, a, b): x = [a[i] + b[i] for i in range(n)] y = [a[i] - b[i] for i in range(n)] return (sumofDiff(n, x) + sumofDiff(n, y)) * pow2 n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) alice = 2 * (sumofMax(n, a, b) - sumofMax(n, [m * a[i] for i in range(n)], [(m + 1) * b[i] for i in range(n)]) + sumofMax(n, [m * a[i] for i in range(n)], [m * b[i] for i in range(n)])) bob = 2 * (sumofMax(n, a, b) - sumofMax(n, [(m + 1) * a[i] for i in range(n)], [m * b[i] for i in range(n)]) + sumofMax(n, [m * a[i] for i in range(n)], [m * b[i] for i in range(n)])) print((alice) % mod, (bob) % mod)