#include using namespace std; #if __has_include("all.hpp") #include "all.hpp" #else #include #endif using namespace atcoder; using mint =modint1000000007; struct R{ //>=0&&de!=0 long long nu,de; bool operator<(const R& other) const { return (__int128)nu*other.de<(__int128)de*other.nu; } bool operator==(const R& other) const { return (__int128)nu*other.de==(__int128)de*other.nu; } R operator+(const R& other) const { return {nu*other.de+de*other.nu,de*other.de}; } }; int main(void){ int n; cin>>n; long long sum=0; vector>d; vectora(n),b(n); for(int i=0;i>a[i]; for(int i=0;i>b[i]; for(int i=0;i