mod=10**9+7 n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) def f(x): y=sorted(x) res,sm=0,0 for i in range(n): res=(res+y[i]%mod*i-sm)%mod sm=(sm+y[i])%mod return res def g(x,y): u,v=[],[] for i in range(n): u.append(x[i]-y[i]) v.append(x[i]+y[i]) return (f(u)+f(v))%mod def calc(x,y): m=2*10**9 return ((m+1)*g(x,y)-g([m*i for i in x],[(m+1)*i for i in y]))%mod print(calc(a,b),calc(b,a))