#include #include #include #include #include using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(int i=0; i<(int)(n); i++) using m32 = atcoder::static_modint<1000000007>; int N; vector> A; m32 solve(){ vector> Diag; for(auto [a,b] : A) Diag.push_back(make_pair(a-b, -(a+b))); sort(Diag.begin(), Diag.end()); for(auto& [y,x] : Diag) x *= -1; m32 ans = 0; vector Xsort; for(auto& [y,x] : Diag) Xsort.push_back(x); sort(Xsort.begin(), Xsort.end()); atcoder::fenwick_tree X1(N); atcoder::fenwick_tree X0(N); for(auto [y,x] : Diag){ int xc = lower_bound(Xsort.begin(), Xsort.end(), x) - Xsort.begin(); ans += X1.sum(0,xc) * m32(x+y); ans -= X0.sum(0,xc); X1.add(xc, m32(1)); X0.add(xc, m32(x+y)); } return ans; } int main(){ cin >> N; A.resize(N); rep(i,N) cin >> A[i].first; rep(i,N) cin >> A[i].second; m32 ans[2]; rep(t,2){ ans[t] = solve().val(); for(auto& [u,v] : A) swap(u,v); } cout << ans[0].val() << ' ' << ans[1].val() << '\n'; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;