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=0 for i in range(n): res+=y[i]%mod*(2*i-n+1) res%=mod return res def g(x,y): u,v=[0]*n,[0]*n for i in range(n): u[i]=x[i]-y[i] v[i]=x[i]+y[i] return (f(u)+f(v))%mod m=2*10**9 res=(m+1)*g(a,b)%mod res1=g([m*i for i in a],[(m+1)*i for i in b]) res2=g([m*i for i in b],[(m+1)*i for i in a]) print((res-res1)%mod,(res-res2)%mod)